From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4413 invoked by alias); 4 Jan 2012 14:59:21 -0000 Received: (qmail 4399 invoked by uid 22791); 4 Jan 2012 14:59:20 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jan 2012 14:59:06 +0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51600] [4.7 Regression] ice in estimate_local_effects Date: Wed, 04 Jan 2012 14:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg00409.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51600 --- Comment #6 from Jan Hubicka 2012-01-04 14:57:34 UTC --- Estimate_edge_devirt_benefit seems to not make much of sense in mixing the effects of inlining into the local size. Unforutnately we don't really have much infrastructure for similar cases. For 4.8 I plan to add benefit metrics that allows inline-analysis to hint inliner that the inlining is cool idea besides the local code size/time improvements. I am testing the following patch. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 182871) +++ ipa-inline-analysis.c (working copy) @@ -2204,9 +2204,9 @@ estimate_edge_devirt_benefit (struct cgr tree target; struct cgraph_node *callee; struct inline_summary *isummary; - int edge_size = 0, edge_time = 0; + int edge_size, edge_time, time_diff, size_diff; - if (!known_vals || !known_binfos) + if (!known_vals && !known_binfos) return; target = ipa_get_indirect_edge_target (ie, known_vals, known_binfos); @@ -2214,10 +2214,12 @@ estimate_edge_devirt_benefit (struct cgr return; /* Account for difference in cost between indirect and direct calls. */ - *size -= ((eni_size_weights.indirect_call_cost - eni_size_weights.call_cost) - * INLINE_SIZE_SCALE); - *time -= ((eni_time_weights.indirect_call_cost - eni_time_weights.call_cost) - * INLINE_TIME_SCALE * prob / REG_BR_PROB_BASE); + size_diff = ((eni_size_weights.indirect_call_cost - eni_size_weights.call_cost) + * INLINE_SIZE_SCALE); + *size -= size_diff; + time_diff = ((eni_time_weights.indirect_call_cost - eni_time_weights.call_cost) + * INLINE_TIME_SCALE * prob / REG_BR_PROB_BASE); + *time -= time_diff; callee = cgraph_get_node (target); if (!callee || !callee->analyzed) @@ -2229,21 +2231,18 @@ estimate_edge_devirt_benefit (struct cgr estimate_edge_size_and_time (ie, &edge_size, &edge_time, prob); /* Count benefit only from functions that definitely will be inlined - if additional context from NODE's caller were available. */ - if (edge_size >= isummary->size * INLINE_SIZE_SCALE) + if additional context from NODE's caller were available. + + We just account overall size change by inlining. TODO: + we really need to add sort of benefit metrics for these kind of + cases. */ + if (edge_size - size_diff >= isummary->size * INLINE_SIZE_SCALE) { /* Subtract size and time that we added for edge IE. */ - *size -= edge_size; - *time -= edge_time; + *size -= edge_size - size_diff; - /* Subtract benefit from inlining devirtualized call. */ - *size -= edge_size - isummary->size * INLINE_SIZE_SCALE; - *time -= edge_time - (isummary->time * INLINE_TIME_SCALE * prob - / REG_BR_PROB_BASE); - - /* TODO: estimate benefit from optimizing CALLEE's body provided - additional context from IE call site. - For insipiration see ipa-cp.c: devirtualization_time_bonus(). */ + /* Account inlined call. */ + *size += isummary->size * INLINE_SIZE_SCALE; } }