From patchwork Tue Dec 10 03:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xionghu Luo X-Patchwork-Id: 1206893 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-515567-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DfnCcOPG"; 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 47X5Q44HdJz9sR8 for ; Tue, 10 Dec 2019 14:38:49 +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:from :to:cc:subject:date:mime-version:content-transfer-encoding :message-id; q=dns; s=default; b=fSTlfcqpY9JMUvpZ+LUtS/rdUGhNasQ mLssC5Jt4LyHvdP9sCJf6mpjLj4jgt5SeoGLIHu8/7OJwbNNptxEo42j0ViDZGdO QMxlXzBfGMPBwA2ziT2SxnPX0Q21HcyywjqD4ikWfX3vn22qEcmuDuOsUELFKVf1 eqBrtG0VSbX4= 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:from :to:cc:subject:date:mime-version:content-transfer-encoding :message-id; s=default; bh=6Wf0cq7NwUzv69EShjJSsSXNKA0=; b=DfnCc OPGukiwGTesIxenZZ3fgTMYdNmhziimF0MKzwVdtRoiZ/hZ5jzvZRdMu1x5Kh1un Lo7atM3czclN/o+br+v/1Bfr2WARby4pmOwjilmoT44Xfe9nEfEbmowz3iaDef93 o8NULNDkvmdvEJhECLy7IBpdmSTYFRY57NAKtg= Received: (qmail 109252 invoked by alias); 10 Dec 2019 03:38:41 -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 109155 invoked by uid 89); 10 Dec 2019 03:38:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*wschmidt, HX-Languages-Length:3978, 23277 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 03:38:39 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBA3b5sJ135813 for ; Mon, 9 Dec 2019 22:38:37 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wsnfe7uqb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 09 Dec 2019 22:38:37 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Dec 2019 03:38:35 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 10 Dec 2019 03:38:32 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBA3cUpx45154374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2019 03:38:30 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92ED152054; Tue, 10 Dec 2019 03:38:30 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7C4C152051; Tue, 10 Dec 2019 03:38:29 +0000 (GMT) From: Xiong Hu Luo To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, wschmidt@linux.ibm.com, guojiufu@linux.ibm.com, linkw@gcc.gnu.org, fxue@os.amperecomputing.com, Xiong Hu Luo Subject: [RFC] ipa-cp: Fix PGO regression caused by r278808 Date: Mon, 9 Dec 2019 21:38:22 -0600 MIME-Version: 1.0 x-cbid: 19121003-0020-0000-0000-000003960AB4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19121003-0021-0000-0000-000021ED4922 Message-Id: <20191210033822.124374-1-luoxhu@linux.ibm.com> The performance of exchange2 built with PGO will decrease ~28% by r278808 due to profile count set incorrectly. The cloned nodes are updated to a very small count caused later pass cunroll fail to unroll the recursive function in exchange2, This patch enables adding orig_sum to the new nodes for self recursive node. digits_2 -> digits_2.constprop.0, digits_2.constprop.1, etc. gcc/ChangeLog: 2019-12-10 Luo Xiong Hu * ipa-pure-const.c (self_recursive_p): Move it from ... (propagate_pure_const): Use cgraph_node::self_recursive_p. (pass_nothrow::execute): Likewise. * cgraph.h (cgraph_node::self_recursive_p): to ... this. * ipa-cp.c (update_profiling_info): Check self_recursive_p node. --- gcc/cgraph.h | 18 ++++++++++++++++++ gcc/ipa-cp.c | 5 ++++- gcc/ipa-pure-const.c | 19 ++----------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index cdeea4d9953..1aca7d114e9 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1329,6 +1329,9 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node /* Return true if function should be optimized for size. */ bool optimize_for_size_p (void); + /* Return true if NODE is self recursive function. */ + inline bool self_recursive_p (void); + /* Dump the callgraph to file F. */ static void dump_cgraph (FILE *f); @@ -3285,6 +3288,21 @@ cgraph_node::optimize_for_size_p (void) return false; } +/* Return true if NODE is self recursive function. + Indirectly recursive functions appears as non-trivial strongly + connected components, so we need to care about self recursion + only. */ + +inline bool +cgraph_node::self_recursive_p (void) +{ + struct cgraph_edge *e; + for (e = this->callees; e; e = e->next_callee) + if (e->callee->function_symbol () == this) + return true; + return false; +} + /* Return symtab_node for NODE or create one if it is not present in symtab. */ diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 14064ae0034..76c1b309d04 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -4305,7 +4305,10 @@ update_profiling_info (struct cgraph_node *orig_node, remainder = remainder.guessed_local (); new_sum = orig_node_count.combine_with_ipa_count (new_sum); - new_node->count = new_sum; + if (orig_node->self_recursive_p ()) + new_node->count = (orig_sum + new_sum).apply_scale (5, 10); + else + new_node->count = new_sum; orig_node->count = remainder; profile_count::adjust_for_ipa_scaling (&new_sum, &orig_new_node_count); diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index a142e0cc8f6..520ed39b476 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1371,21 +1371,6 @@ ignore_edge_for_nothrow (struct cgraph_edge *e) || !opt_for_fn (ultimate_target->decl, flag_ipa_pure_const)); } -/* Return true if NODE is self recursive function. - Indirectly recursive functions appears as non-trivial strongly - connected components, so we need to care about self recursion - only. */ - -static bool -self_recursive_p (struct cgraph_node *node) -{ - struct cgraph_edge *e; - for (e = node->callees; e; e = e->next_callee) - if (e->callee->function_symbol () == node) - return true; - return false; -} - /* Return true if N is cdtor that is not const or pure. In this case we may need to remove unreachable function if it is marked const/pure. */ @@ -1666,7 +1651,7 @@ propagate_pure_const (void) if (this_state == IPA_NEITHER) this_looping = w_l->looping_previously_known; } - if (!this_looping && self_recursive_p (w)) + if (!this_looping && w->self_recursive_p ()) this_looping = true; if (!w_l->looping_previously_known) this_looping = false; @@ -2342,7 +2327,7 @@ pass_nothrow::execute (function *) node->set_nothrow_flag (true); bool cfg_changed = false; - if (self_recursive_p (node)) + if (node->self_recursive_p ()) FOR_EACH_BB_FN (this_block, cfun) if (gimple *g = last_stmt (this_block)) if (is_gimple_call (g))