From patchwork Thu Sep 26 22:17:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Xu X-Patchwork-Id: 278285 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 963A72C0339 for ; Fri, 27 Sep 2013 08:17:42 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=uiYgTJLhhAZHfGM2T9hgAuL4t7QSOWojXB4Yf9O31Lq 8lzEfxDeu9at6r+pMeLwtvGhj+Cn4roVKvz0sfyaVynjlZttjf12Z4Ym9RP61YwA MFAD+S+1GKaBpcs12bL2eM3MCeeAz9PRjM45WPoWr2KCNMdwU3E3YFukuDUzaJao = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=BJrisnfyAXso+LoLMpiRnzB28Pk=; b=Y38fBhBbOjUtP5Ui8 w7eo6CJ3DHtSFsTZanXDm+cAy0z5XX4NC6nU0jIwxLBKPTHuIfyFCQcGEpd9CJ/c cnpTQ7DD2MT6sKkGG9vIpnUbq24CN5HDUHHx2S4lyDfeR0HxtCB9p9fArOUWTonX 2yTSAgmtzSSc/m7pGA+0bZiRQk= Received: (qmail 20510 invoked by alias); 26 Sep 2013 22:17:25 -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 20403 invoked by uid 89); 26 Sep 2013 22:17:25 -0000 Received: from mail-ob0-f176.google.com (HELO mail-ob0-f176.google.com) (209.85.214.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 26 Sep 2013 22:17:25 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.3 required=5.0 tests=AWL, BAYES_50, NO_RELAYS, SPAM_SUBJECT autolearn=no version=3.3.2 X-HELO: mail-ob0-f176.google.com Received: by mail-ob0-f176.google.com with SMTP id uy5so2600340obc.21 for ; Thu, 26 Sep 2013 15:17:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=imoPvtkvBx6t6EaNRsuKg76B+kasBKOmavXgFsETdJg=; b=Ikgh/+722PBmdkpX58uVTJeCJpd9CLWKPv5ZWQbSI1fdHhI69D/7dqok4wVIwQpBem YwEfPFe2kxObWFLDsEtDFCofc5NTCeOfcs0BoLdkMKyFyg/XyM+MmHQNfBgUq27PQEK1 hKai563Qp1wYhDgO6H1+rx1+we2VjwphGpF5Bm2i4ajEcvJhtgh1HjVfrTQHk14iPlYj KBz3w4a9Qqmd86eMn/8CCURDPv4Q/WUkbNHY3a2/LP29I3SHJ9pDS6AnCbkIPO4qPaT0 qy6UAqvr3bLzLCYcuHwEY8nHmr40jMkoVfMsw9tV4pWNvddG1h4ENHt3nbkrgoofLSCt FwMA== X-Gm-Message-State: ALoCoQn2Z0xXdrpbTiRczxpke1NJ12jmL3N9GeVCk8FNOFbnrNRV+e9mNJDVAzjlK5n0Ldp7KYGqbN5vnsmoOwz9GxZIYxrGZhKW/SiDU7sUiDb3ROwjacBWIY37StW22bWBHjTSvvvp5cObtc2NGEYcN12iCu+KtB5MyFet5PO874MRrD9rgMSRo54s0L3RWyA0VcPL+zVl/i2xzsXL+UjDp4OobVAmmg== MIME-Version: 1.0 X-Received: by 10.182.60.194 with SMTP id j2mr2758088obr.2.1380233843053; Thu, 26 Sep 2013 15:17:23 -0700 (PDT) Received: by 10.182.32.39 with HTTP; Thu, 26 Sep 2013 15:17:22 -0700 (PDT) Date: Thu, 26 Sep 2013 15:17:22 -0700 Message-ID: Subject: [google gcc-4_8] alternate hirate for builtin_expert From: Rong Xu To: GCC Patches Cc: David Li , Jan Hubicka X-IsSubscribed: yes Hi, Current default probably for builtin_expect is 0.9996. This makes the freq of unlikely bb very low (4), which suppresses the inlining of any calls within those bb. We used FDO data to measure the branch probably for the branch annotated with builtin_expert. For google internal benchmarks, the weight average (the profile count value as the weight) is 0.9081. Linux kernel is another program that is heavily annotated with builtin-expert. We measured its weight average as 0.8717, using google search as the workload. This patch sets the alternate hirate probability for builtin_expert to 90%. With the alternate hirate, we measured performance improvement for google benchmarks and Linux kernel. -Rong 2013-09-26 Rong Xu * params.def (DEFPARAM): New. * params.def: New. * predict.c (tree_predict_by_opcode): Alternate probablity hirate for builtin_expect. Index: params.def =================================================================== --- params.def (revision 202638) +++ params.def (working copy) @@ -483,6 +483,10 @@ DEFPARAM(TRACER_MIN_BRANCH_PROBABILITY, "tracer-min-branch-probability", "Stop forward growth if the probability of best edge is less than this threshold (in percent). Used when profile feedback is not available", 50, 0, 100) +DEFPARAM(BUILTIN_EXPECT_PROBABILITY_RELAXED, + "builtin-expect-probability-relaxed", + "Set the estimated probability for builtin expect. By default using PROB_VERY_LIKELY, while value of 1 using HIRATE(90) probability.", + 0, 0, 1) /* The maximum number of incoming edges to consider for crossjumping. */ DEFPARAM(PARAM_MAX_CROSSJUMP_EDGES, Index: params.def =================================================================== --- params.def (revision 202638) +++ params.def (working copy) @@ -483,6 +483,10 @@ DEFPARAM(TRACER_MIN_BRANCH_PROBABILITY, "tracer-min-branch-probability", "Stop forward growth if the probability of best edge is less than this threshold (in percent). Used when profile feedback is not available", 50, 0, 100) +DEFPARAM(BUILTIN_EXPECT_PROBABILITY_RELAXED, + "builtin-expect-probability-relaxed", + "Set the estimated probability for builtin expect. By default using PROB_VERY_LIKELY, while value of 1 using HIRATE(90) probability.", + 0, 0, 1) /* The maximum number of incoming edges to consider for crossjumping. */ DEFPARAM(PARAM_MAX_CROSSJUMP_EDGES, Index: predict.c =================================================================== --- predict.c (revision 202638) +++ predict.c (working copy) @@ -1950,10 +1950,17 @@ tree_predict_by_opcode (basic_block bb) BITMAP_FREE (visited); if (val) { + enum br_predictor predictor; + + if (PARAM_VALUE (BUILTIN_EXPECT_PROBABILITY_RELAXED) == 0) + predictor = PRED_BUILTIN_EXPECT; + else + predictor = PRED_BUILTIN_EXPECT_RELAXED; + if (integer_zerop (val)) - predict_edge_def (then_edge, PRED_BUILTIN_EXPECT, NOT_TAKEN); + predict_edge_def (then_edge, predictor, NOT_TAKEN); else - predict_edge_def (then_edge, PRED_BUILTIN_EXPECT, TAKEN); + predict_edge_def (then_edge, predictor, TAKEN); return; } /* Try "pointer heuristic."