From patchwork Tue Apr 12 09:48:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 52810 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 940153856DD4 for ; Tue, 12 Apr 2022 09:49:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 940153856DD4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649756940; bh=bHxRiyg9OLm1er/QW8OPKjLmJmhNSkEkXxOFSKFwLRI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kh40WtZks48HhoYrpjHNxKeU76mn5juClvrhqA3e7jKl2MngixRqTSDh0KNFxgBhM ZS8JxEAbRtUFYv8K9MXcuEs7v+zTHl1JadPhTMKeOuBjgUfUB64WxyTBoyp8FrZXu4 ZYZEbh//Z0+ZtBhPGJKvbLknBNG8rYBIfKFGkRA4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B79363858C54 for ; Tue, 12 Apr 2022 09:48:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B79363858C54 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7013C21608 for ; Tue, 12 Apr 2022 09:48:18 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5C76313A99 for ; Tue, 12 Apr 2022 09:48:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sNZwFeJKVWJJNgAAMHmgww (envelope-from ) for ; Tue, 12 Apr 2022 09:48:18 +0000 Date: Tue, 12 Apr 2022 11:48:18 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105235 - clean EH in execute_cse_conv_1 MIME-Version: 1.0 Message-Id: <20220412094818.5C76313A99@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When a FP conversion is removed we have to eventually clean EH. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-04-12 Richard Biener PR tree-optimization/105235 * tree-ssa-math-opts.cc (execute_cse_conv_1): Clean EH and return whether the CFG changed. (execute_cse_sincos_1): Adjust. * g++.dg/opt/pr105235-1.C: New testcase. --- gcc/testsuite/g++.dg/opt/pr105235-1.C | 12 ++++++++++++ gcc/tree-ssa-math-opts.cc | 15 +++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr105235-1.C diff --git a/gcc/testsuite/g++.dg/opt/pr105235-1.C b/gcc/testsuite/g++.dg/opt/pr105235-1.C new file mode 100644 index 00000000000..b74d2034f5b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr105235-1.C @@ -0,0 +1,12 @@ +// PR tree-optimization/105235 +// { dg-do compile } +// { dg-options "-O -fno-tree-dominator-opts -fexceptions -fnon-call-exceptions -fno-tree-fre" } + +struct S { ~S (); }; + +double +foo (double d) +{ + S s; + return __builtin_ilogbl (d) + __builtin_sinl (d); +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index ac277756d24..102b7a2cc99 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -1113,7 +1113,7 @@ make_pass_cse_reciprocals (gcc::context *ctxt) conversions. Return the prevailing name. */ static tree -execute_cse_conv_1 (tree name) +execute_cse_conv_1 (tree name, bool *cfg_changed) { if (SSA_NAME_IS_DEFAULT_DEF (name) || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) @@ -1189,15 +1189,18 @@ execute_cse_conv_1 (tree name) || !types_compatible_p (TREE_TYPE (name), TREE_TYPE (lhs))) continue; - if (gimple_bb (def_stmt) == gimple_bb (use_stmt) - || dominated_by_p (CDI_DOMINATORS, gimple_bb (use_stmt), - gimple_bb (def_stmt))) + basic_block use_bb = gimple_bb (use_stmt); + if (gimple_bb (def_stmt) == use_bb + || dominated_by_p (CDI_DOMINATORS, use_bb, gimple_bb (def_stmt))) { sincos_stats.conv_removed++; gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt); replace_uses_by (lhs, name); - gsi_remove (&gsi, true); + if (gsi_remove (&gsi, true) + && gimple_purge_dead_eh_edges (use_bb)) + *cfg_changed = true; + release_defs (use_stmt); } } @@ -1252,7 +1255,7 @@ execute_cse_sincos_1 (tree name) int i; bool cfg_changed = false; - name = execute_cse_conv_1 (name); + name = execute_cse_conv_1 (name, &cfg_changed); FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, name) {