From patchwork Sat Nov 9 17:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1192468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512882-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bOIEQF8d"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 479Pdr425sz9s4Y for ; Sun, 10 Nov 2019 04:44:16 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=ehpqoZCYZoh/YQ6qumY3qqip29Nk4mkGcHAYnMLPx8/bpyrM+l9AB 2tCJSti44ebCS69l/aAMPvfLhh0epTTXhPRkOypFOtokzgZEM3ZvtwAlV3xUREkJ lqxeHyldh5FG3punmO1iSW8Hdo707qgXrilbN8yXJ1gHvUTh7fuxns= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=jvu1rOuDQLmhHZH6iKVHabBgKGQ=; b=bOIEQF8daILcL56Jj6ZO A9Er3XlDQ/ByM8A/XNVlF1QvdPeoDHdi4y6sfgUX2BbN3pFIax1Ch/Qv4qt7Z7zh y3WUeHGwhwR68t6iHgm0l8BZPEEs23oJ5VuYVNFFLIhRDSpH2f1XANa/HhqerIbp f2feUIFRoK+KUepzwW+zMfg= Received: (qmail 84214 invoked by alias); 9 Nov 2019 17:44:09 -0000 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 Received: (qmail 84199 invoked by uid 89); 9 Nov 2019 17:44:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=vnull, vNULL, unconditional X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Nov 2019 17:44:08 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id D672428288C; Sat, 9 Nov 2019 18:44:05 +0100 (CET) Date: Sat, 9 Nov 2019 18:44:05 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix computation of min_size in ipa-fnsummary.c Message-ID: <20191109174405.c2bmicjtclr3vadu@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch fixes two different bugs in computation of min_size in ipa-fnsummary.c. This computes minimal size of any clone or version of given function and is used to avoid some harder work to compute actual size for given context in the inlining heuristics. In estimate_size_and_time we mistakely reset min_size to size of first entry of size/time table (which is only unconditional entry) forgetting that it already cumulated info about calls sizes. In update_overall_fn_summary we forgot to account the size/time table and then divide result by size scale. Bootstrapped/regtested x86_64-linux, comitted. Honza * ipa-fnsummary.c (ipa_call_context::estimate_size_and_time): Fix calculation of min_size. (ipa_update_overall_fn_summary): Likewise. Index: ipa-fnsummary.c =================================================================== --- ipa-fnsummary.c (revision 278005) +++ ipa-fnsummary.c (working copy) @@ -3243,6 +3243,7 @@ ipa_call_context::estimate_size_and_time sreal nonspecialized_time = time; + min_size += (*info->size_time_table)[0].size; for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++) { bool exec = e->exec_predicate.evaluate (m_nonspec_possible_truths); @@ -3288,7 +3289,7 @@ ipa_call_context::estimate_size_and_time } gcc_checking_assert ((*info->size_time_table)[0].exec_predicate == true); gcc_checking_assert ((*info->size_time_table)[0].nonconst_predicate == true); - min_size = (*info->size_time_table)[0].size; + gcc_checking_assert (min_size >= 0); gcc_checking_assert (size >= 0); gcc_checking_assert (time >= 0); /* nonspecialized_time should be always bigger than specialized time. @@ -3685,12 +3686,13 @@ ipa_update_overall_fn_summary (struct cg size_info->size += e->size; info->time += e->time; } + info->min_size = (*info->size_time_table)[0].size; estimate_calls_size_and_time (node, &size_info->size, &info->min_size, &info->time, NULL, ~(clause_t) (1 << predicate::false_condition), vNULL, vNULL, vNULL); - size_info->size = (size_info->size + ipa_fn_summary::size_scale / 2) - / ipa_fn_summary::size_scale; + size_info->size = RDIV (size_info->size, ipa_fn_summary::size_scale); + info->min_size = RDIV (info->min_size, ipa_fn_summary::size_scale); }