From patchwork Mon Dec 12 16:52:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 32455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2350190wrr; Mon, 12 Dec 2022 08:54:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7aOzxSaYu46pAHe74UZSM6yI69c+EgtNaFrI2tDpCEg0O31AIvV8nB7haRUBDtKYvI/Huu X-Received: by 2002:a05:6402:5303:b0:462:7b87:c6d with SMTP id eo3-20020a056402530300b004627b870c6dmr14399270edb.2.1670864091399; Mon, 12 Dec 2022 08:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670864091; cv=none; d=google.com; s=arc-20160816; b=z/UgHwsRS6LyuvYyqVtylvN62y51OwtfUbycSqtm2PvdUSAuOB8FKdGiJ/bIBEKKcM szXem73mvNGDV6Mhd/+7pitnCu4A2Il5YlYdr00irKjrRjT+md5uhpvBYqhrZIFpq/JT vKbhlNBMsuFIXCWJnvSTKTqUPLrO1R787qDc27mhNHBmzQU52hICKhx4MtKzXrBH2wGJ RoYooRBhTu8MLAbogqH4cltCPhoji5NgD2l9M7dy/oGRn0akhCPhszritrAyBB6Ufiiq YvTS1hjQ2D0KX6icjV2oHwqtEHKmQZDEX/vvsCK3EGZhVSpB4tKbghrn4m6PzZJSsPJ3 WtUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:subject:cc:to:from:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=Onw6lHOKxijugsBXr9fwz8EynUIyTPu+A1svDCmMZ6c=; b=aG0+g56ykqIiS6vQICTS5tXbJTzCdIg7EAJPUwED/ydQa8IyDoV4k2LOrqVukzp2WA us4rl1jl8d8+IGH1bDcSVg+PEab2QzniA/MGfkPoWL9QGVq6P/+SaPVIvL961et3i8Ps 0YwrL/GaISc/dzATh7bqtEjdbzzvs1nHlBvci04NYI76q1eCOPxR4h4LsoVhQplJg81p wX2+DVWlxtE/vkjJ1cRJ92aMUbZ28sbfWB8TuVu09E3uPEjO3B25EzE9sv9cfjp/lZYE iWrRNECnjg1GybxaglErcfgsGcQxoHA6RJa+wb/pilChhmr978FUwgxzodoQolEIAz3m bAzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lLsO8fKZ; dkim=neutral (no key) header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a38-20020a509ea9000000b004573107a5basi7859631edf.352.2022.12.12.08.54.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 08:54:51 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lLsO8fKZ; dkim=neutral (no key) header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 495103850B2D for ; Mon, 12 Dec 2022 16:53:50 +0000 (GMT) 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 2F9E3385B530 for ; Mon, 12 Dec 2022 16:52:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F9E3385B530 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-out1.suse.de (Postfix) with ESMTPS id 664AC3393D; Mon, 12 Dec 2022 16:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1670863947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=Onw6lHOKxijugsBXr9fwz8EynUIyTPu+A1svDCmMZ6c=; b=lLsO8fKZnG7ctE3F+q/aB6W7iuiJy08W9sAejpH0h6A1lNRdgiQ1LbUDYfPXrUfXLz/zfT Ll6usS0lHyGppG6lgKOmhcn+31/YnV3ekKdg7vj42QJPiSXEZBv0R+p9JgjWUDgalmwfFy XbIxZAEHyP/DXuD0LvJYclIniepXp7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1670863947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=Onw6lHOKxijugsBXr9fwz8EynUIyTPu+A1svDCmMZ6c=; b=36LnFFWsxHXaihdoIQXl2AYIlhD8qJRHwzQgpvUq53YkGU8LGvc6F6ciPbDJMCRtfgjKK+ ZNGugIdU/YriGkAQ== 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 5844713456; Mon, 12 Dec 2022 16:52:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TVl+FUtcl2OHEgAAMHmgww (envelope-from ); Mon, 12 Dec 2022 16:52:27 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Jan Hubicka Subject: [PATCH 3/9] ipa-cp: Leave removal of unused parameters to IPA-SRA User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.1 (x86_64-suse-linux-gnu) Date: Mon, 12 Dec 2022 17:52:26 +0100 Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752027985599797628?= X-GMAIL-MSGID: =?utf-8?q?1752027985599797628?= Hi, I'm re-posting patches which I have posted at the end of stage 1 but which have not passed review yet. 8<-------------------------------------------------------------------- Looking at some benchmarks I have noticed many cases when IPA-CP cloned a function for all contexts just because it knew that some parameters were not used at all. Then IPA-SRA looked at the function and cloned it again to split another parameter or two. The latter pass is better equipped to detect when parameters can be altogether removed and so the IPA-CP cloning was for no good reason. This patch simply alters the IPA-CP not to do that in the situations where IPA-SRA can (for nodes which can be made local). Bootstrapped and tested individually when I originally posted it and now bootstrapped and LTO-bootstrapped and tested as part of the whole series. OK for master? gcc/ChangeLog: 2022-11-11 Martin Jambor * ipa-cp.cc (estimate_local_effects): Do not clone potentionally local nodes for all contexts just to remove unused parameters. --- gcc/ipa-cp.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index cc031ebed0f..172ea353c49 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -3722,7 +3722,10 @@ estimate_local_effects (struct cgraph_node *node) &removable_params_cost); int devirt_bonus = devirtualization_time_bonus (node, &avals); if (always_const || devirt_bonus - || (removable_params_cost && node->can_change_signature)) + || (removable_params_cost + && node->can_change_signature + /* If IPA-SRA can do it, it can do it better. */ + && !node->can_be_local_p ())) { struct caller_statistics stats; ipa_call_estimates estimates;