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 154613858D37 for ; Thu, 6 Aug 2020 10:20:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 154613858D37 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 4ADFDAD83 for ; Thu, 6 Aug 2020 10:20:52 +0000 (UTC) Date: Thu, 6 Aug 2020 12:20:35 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/96491 - avoid store commoning across abnormal edges 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=-10.1 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: Thu, 06 Aug 2020 10:20:37 -0000 This avoids store commoning across abnormal edges since that easily can disrupt abnormal coalescing because it might create overlapping lifetime of variables. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2020-08-06 Richard Biener PR tree-optimization/96491 * tree-ssa-sink.c (sink_common_stores_to_bb): Avoid sinking across abnormal edges. * gcc.dg/torture/pr96491.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr96491.c | 29 ++++++++++++++++++++++++++ gcc/tree-ssa-sink.c | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr96491.c diff --git a/gcc/testsuite/gcc.dg/torture/pr96491.c b/gcc/testsuite/gcc.dg/torture/pr96491.c new file mode 100644 index 00000000000..784559f4754 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr96491.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +int rj; + +void __attribute__ ((returns_twice)) +da (void) +{ + rj = 1; +} + +void +c5 (void) +{ + for (;;) + ++rj; +} + +void +ls (int kz) +{ + if (kz == 0) + { + rj = 0; + c5 (); + } + + da (); + c5 (); +} diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index 962ad076968..4cc5195f2f8 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -503,7 +503,8 @@ sink_common_stores_to_bb (basic_block bb) tree arg = gimple_phi_arg_def (phi, i); gimple *def = SSA_NAME_DEF_STMT (arg); if (! is_gimple_assign (def) - || stmt_can_throw_internal (cfun, def)) + || stmt_can_throw_internal (cfun, def) + || (gimple_phi_arg_edge (phi, i)->flags & EDGE_ABNORMAL)) { /* ??? We could handle some cascading with the def being another PHI. We'd have to insert multiple PHIs for -- 2.26.2