From patchwork Mon Jul 15 02:42:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xionghu Luo X-Patchwork-Id: 1131830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505075-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="D1u8lzHB"; 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 45n7Bm0J1Gz9s7T for ; Mon, 15 Jul 2019 12:43:42 +1000 (AEST) 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=LYPP45U0uLXACiCfyyPyUmXapn1DoSD 1hVTHqc2J/efArW/+Cyko5pQyUmwKnP43shCAms9w0yGA+qkXMf1rJo9CG8fLRoP /ua5sHfmaFZR7pW7l4bQ5To9tNeADRypq0qQ+mVLf5VS7wHupSVDaKoIgXFDo/+y 682yMD7/pimY= 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=Ybwq92JSSOquYdFQuvKWagA+aLw=; b=D1u8l zHBD9ArpXYWi51HKpNzIKDIPc+5I1ZBWhIwBekXgg7KzhEEazQQWGCb7r1eOnvFl RroH5ic3eGFHiCWCJ35y4TJXZT4TYyHgf6zVG5x74BygMjSZWPsF/iz2fDv7ulAd ZIOdaFW85UdIw4JnAkcScj74LkHAexEqPopwIk= Received: (qmail 116185 invoked by alias); 15 Jul 2019 02:43:35 -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 116177 invoked by uid 89); 15 Jul 2019 02:43:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:D*cz, luo, HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Jul 2019 02:43:33 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6F2gLTe082525 for ; Sun, 14 Jul 2019 22:43:32 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2trbjfrekv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 14 Jul 2019 22:43:31 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jul 2019 03:43:29 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Jul 2019 03:43:28 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6F2hPJe59375782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Jul 2019 02:43:25 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C34B442041; Mon, 15 Jul 2019 02:43:25 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ECD24203F; Mon, 15 Jul 2019 02:43:25 +0000 (GMT) Received: from moose1.pok.stglabs.ibm.com (unknown [9.114.13.14]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 15 Jul 2019 02:43:25 +0000 (GMT) From: Xiong Hu Luo To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz, mliska@suse.cz, segher@kernel.crashing.org, wschmidt@linux.ibm.com, luoxhu@linux.ibm.com Subject: [PATCH] Generalize get_most_common_single_value to return k_th value & count Date: Sun, 14 Jul 2019 22:42:11 -0400 MIME-Version: 1.0 x-cbid: 19071502-0028-0000-0000-00000384407B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071502-0029-0000-0000-000024445C19 Message-Id: <20190715024211.114554-1-luoxhu@linux.ibm.com> Currently get_most_common_single_value could only return the max hist , add two paramter to enable this function return kth value if needed. gcc/ChangeLog: 2019-07-15 Xiong Hu Luo * value-prof.c (get_most_common_single_value): Add input params k_th and k, return the k_th if k_th is true. * value-prof.h (get_most_common_single_value): Add input params k_th and k, default to false. --- gcc/value-prof.c | 16 ++++++++++++---- gcc/value-prof.h | 7 +++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 32e6ddd8165..e1a3e0bd4b5 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -719,9 +719,9 @@ gimple_divmod_fixed_value (gassign *stmt, tree value, profile_probability prob, bool get_most_common_single_value (gimple *stmt, const char *counter_type, - histogram_value hist, - gcov_type *value, gcov_type *count, - gcov_type *all) + histogram_value hist, gcov_type *value, + gcov_type *count, gcov_type *all, bool k_th, + unsigned k) { if (hist->hvalue.counters[2] == -1) return false; @@ -743,7 +743,15 @@ get_most_common_single_value (gimple *stmt, const char *counter_type, *all = read_all; - if (c > *count) + /* Return the kth value in hist instead of the max value for indirect + multiple call usage. */ + if (k_th && i == k) + { + *value = v; + *count = c; + break; + } + else if (c > *count) { *value = v; *count = c; diff --git a/gcc/value-prof.h b/gcc/value-prof.h index ca846d08cbd..0a064a71f7d 100644 --- a/gcc/value-prof.h +++ b/gcc/value-prof.h @@ -90,10 +90,9 @@ void stringop_block_profile (gimple *, unsigned int *, HOST_WIDE_INT *); gcall *gimple_ic (gcall *, struct cgraph_node *, profile_probability); bool check_ic_target (gcall *, struct cgraph_node *); bool get_most_common_single_value (gimple *stmt, const char *counter_type, - histogram_value hist, - gcov_type *value, gcov_type *count, - gcov_type *all); - + histogram_value hist, gcov_type *value, + gcov_type *count, gcov_type *all, + bool k_th = false, unsigned k = 0); /* In tree-profile.c. */ extern void gimple_init_gcov_profiler (void);