From patchwork Thu Oct 25 12:24:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 194130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0EA482C009B for ; Thu, 25 Oct 2012 23:24:30 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351772671; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=9r2wHN4bL2atw+YGe14/H+16CBY=; b=HSaPEnKZNK3Xl+W D5R4/xSGsBPLYHjlQRGUpLB6SfoWJNfmHfAY5vmk1d5GPPi5xrQWZfqlQu7BYhiR c+5qEwrMCoysAnlOW49fhivjfOwDxsC1hH2EG5St3995QVg7cBUqMaKCrlEgMZHk 5ZUYSPrrHO6rRTOPUJiGpbYJOeB0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ujbcSu0gCf+mb2oZlmBmXSsMsfegwkTNmimbP/cZKra4Q7qxXAGvVPoTbRo3Az r2qhwI6GMeGOf4xLlcGBZvFv9q8/KCIv8vuHjYuUoQAsJfvZ+LR/1lX1pG+NKBo+ awaXz7MnQSoTWNDXx+mpUDvjF/fp7Tcm7lPV1ZQjdZToo=; Received: (qmail 1981 invoked by alias); 25 Oct 2012 12:24:22 -0000 Received: (qmail 1968 invoked by uid 22791); 25 Oct 2012 12:24:20 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 25 Oct 2012 12:24:14 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 7BA80543AFA; Thu, 25 Oct 2012 14:24:13 +0200 (CEST) Date: Thu, 25 Oct 2012 14:24:13 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix accounting of code growth in recursive inliner Message-ID: <20121025122413.GA8023@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, recursive inliner is confusing the cost of inlining function to itself with cost of inlining the master clone. After first recursive inlining happened those are no longer equivalent. Fixed thus. Bootstrapped/regtested x86_64-linux, committed. Honza * ipa-inline.c (recursive_inlining): Redirect to master clone before testing profitability. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 192788) +++ ipa-inline.c (working copy) @@ -1190,14 +1190,28 @@ recursive_inlining (struct cgraph_edge * { struct cgraph_edge *curr = (struct cgraph_edge *) fibheap_extract_min (heap); - struct cgraph_node *cnode; - - if (estimate_size_after_inlining (node, curr) > limit) - break; + struct cgraph_node *cnode, *dest = curr->callee; if (!can_inline_edge_p (curr, true)) continue; + /* MASTER_CLONE is produced in the case we already started modified + the function. Be sure to redirect edge to the original body before + estimating growths otherwise we will be seeing growths after inlining + the already modified body. */ + if (master_clone) + { + cgraph_redirect_edge_callee (curr, master_clone); + reset_edge_growth_cache (curr); + } + + if (estimate_size_after_inlining (node, curr) > limit) + { + cgraph_redirect_edge_callee (curr, dest); + reset_edge_growth_cache (curr); + break; + } + depth = 1; for (cnode = curr->caller; cnode->global.inlined_to; cnode = cnode->callers->caller) @@ -1206,7 +1220,11 @@ recursive_inlining (struct cgraph_edge * depth++; if (!want_inline_self_recursive_call_p (curr, node, false, depth)) - continue; + { + cgraph_redirect_edge_callee (curr, dest); + reset_edge_growth_cache (curr); + continue; + } if (dump_file) { @@ -1228,9 +1246,10 @@ recursive_inlining (struct cgraph_edge * for (e = master_clone->callees; e; e = e->next_callee) if (!e->inline_failed) clone_inlined_nodes (e, true, false, NULL); + cgraph_redirect_edge_callee (curr, master_clone); + reset_edge_growth_cache (curr); } - cgraph_redirect_edge_callee (curr, master_clone); inline_call (curr, false, new_edges, &overall_size, true); lookup_recursive_calls (node, curr->callee, heap); n++;