From patchwork Sat Nov 12 01:47:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 60472 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 DF96838A908A for ; Sat, 12 Nov 2022 01:48:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id F0B02389EC5F for ; Sat, 12 Nov 2022 01:47:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F0B02389EC5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz 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-out2.suse.de (Postfix) with ESMTPS id 29F7B1F91B; Sat, 12 Nov 2022 01:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668217666; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=KMC5B7R3Qiis6dE5+HF1JMmwSrAZiXeTu1U7gEG6QNg=; b=Lhg1aEnntStdygEp7W3qb6yS5H2D+tCaadqRjOnZK3Vc5UQ8k+8TOQZlV1ULZtr8bIUxB6 62M/gXyUXL1ZXL+G5sv3kPBRR/Ukl1hnHRNd1YE3nUGBqZecq60vj18+cg34Cuz0XAv4Bd DpjwA7kGJdfvpk8IfhfophzgrTYUk1I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668217666; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=KMC5B7R3Qiis6dE5+HF1JMmwSrAZiXeTu1U7gEG6QNg=; b=qUEWNRh8YH128/dSi8ZHbNpoA99bQChrrq751I64Iwz0mMCnLAoSZ0Btbfb6SJUjG79TIX Mh5kkdoYfgjzMEAg== 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 1D2B213A08; Sat, 12 Nov 2022 01:47:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BOYZB0L7bmPOZAAAMHmgww (envelope-from ); Sat, 12 Nov 2022 01:47:46 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Jan Hubicka Subject: [PATCH 12/12] ipa: Avoid looking for IPA-SRA replacements where there are none User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.1 (x86_64-suse-linux-gnu) Date: Sat, 12 Nov 2022 02:47:45 +0100 Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, while modifying the code, I realized that we do look into statements even when there are no replacements. This patch adds the necessary early bail-outs to avoid that. ipa_param_body_adjustments::modify_call_stmt cannot have the same at the very beginning because calls can still contain otherwise removed parameters that need to be removed from the statements too. Bootstrapped and tested on x86_64-linux. OK for master? Thanks, Martin gcc/ChangeLog: 2022-11-11 Martin Jambor * ipa-param-manipulation.cc (ipa_param_body_adjustments::modify_expression): Bail out early if there are no replacements. (ipa_param_body_adjustments::modify_assignment): Likewise. gcc/testsuite/ChangeLog: 2022-11-11 Martin Jambor PR ipa/103227 PR ipa/107640 * gcc.dg/ipa/pr107640-2.c: New test. --- gcc/ipa-param-manipulation.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-param-manipulation.cc b/gcc/ipa-param-manipulation.cc index e92cfc0b6d5..da19d64cbce 100644 --- a/gcc/ipa-param-manipulation.cc +++ b/gcc/ipa-param-manipulation.cc @@ -1762,6 +1762,8 @@ ipa_param_body_adjustments::modify_expression (tree *expr_p, bool convert) { tree expr = *expr_p; + if (m_replacements.is_empty ()) + return false; if (TREE_CODE (expr) == BIT_FIELD_REF || TREE_CODE (expr) == IMAGPART_EXPR || TREE_CODE (expr) == REALPART_EXPR) @@ -1809,7 +1811,7 @@ ipa_param_body_adjustments::modify_assignment (gimple *stmt, tree *lhs_p, *rhs_p; bool any; - if (!gimple_assign_single_p (stmt)) + if (m_replacements.is_empty () || !gimple_assign_single_p (stmt)) return false; rhs_p = gimple_assign_rhs1_ptr (stmt);