From patchwork Wed Jan 27 23:10:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pat Haugen X-Patchwork-Id: 574480 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3401D140C02 for ; Thu, 28 Jan 2016 10:10:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kPJcFOH0; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=htZ0WX5aYSaSiNIAJXcTlPDgUfnS3TTQn6S023+tno3f7VXLPczQb 9IpLJBqm30V4IAIQXgIvJ+ErxnhISxWU8SEb4F/rpst/lagqs5FiJhLtvvM57xmv lN+eTGmVKEIsF8yqByFrLpiNGTdSQ+0czb+tiivJQOeZ/+NV8rxnHE= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=HPvKPXPEOuB8r5jG7Eq4ZwrmtWo=; b=kPJcFOH0TFElC580c6E5 nfw66pUAKaBJSMH7ZJzVhBM/cQ9ge8rYuPHh/WFTSxUb1e16rzOWIZnVhAp2PBEO /7Dz0idd7DDZdbbENkHE/rfy8eTitrDhYc3JLXLMsjpwt38WgA0DBE9GkbSW+zRR lk1oFZJ8A3Enmzku/a+W9J0= Received: (qmail 36621 invoked by alias); 27 Jan 2016 23:10:14 -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 36605 invoked by uid 89); 27 Jan 2016 23:10:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=pat, guessed, prob, highly X-HELO: e17.ny.us.ibm.com Received: from e17.ny.us.ibm.com (HELO e17.ny.us.ibm.com) (129.33.205.207) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 27 Jan 2016 23:10:13 +0000 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jan 2016 18:10:11 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 27 Jan 2016 18:10:09 -0500 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: pthaugen@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 631E06E8041 for ; Wed, 27 Jan 2016 17:57:01 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0RNA8RQ33357928 for ; Wed, 27 Jan 2016 23:10:08 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0RNA8m6012907 for ; Wed, 27 Jan 2016 18:10:08 -0500 Received: from oc1687012634.ibm.com (oc1687012634.ibm.com.rchland.ibm.com [9.10.86.23] (may be forged)) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0RNA72R012797; Wed, 27 Jan 2016 18:10:08 -0500 From: Pat Haugen Subject: [PATCH, rs6000] Disable static branch prediction in absence of real profile data To: GCC Patches , David Edelsohn Message-ID: <56A94E4F.6010306@linux.vnet.ibm.com> Date: Wed, 27 Jan 2016 17:10:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012723-0041-0000-0000-00000320B0A6 X-IsSubscribed: yes The following patch prevents static prediction if we don't have real profile data. Testing on SPEC CPU2006 showed a couple improvements in specint and specfp neutral. Bootstrap/regtest on powerpc64 with no new regressions. Ok for trunk? -Pat 2016-01-27 Pat Haugen * config/rs6000/rs6000.c (output_cbranch): Don't statically predict branches if using guessed profile. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 232881) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -21424,14 +21424,15 @@ output_cbranch (rtx op, const char *labe /* PROB is the difference from 50%. */ int prob = XINT (note, 0) - REG_BR_PROB_BASE / 2; - /* Only hint for highly probable/improbable branches on newer - cpus as static prediction overrides processor dynamic - prediction. For older cpus we may as well always hint, but + /* Only hint for highly probable/improbable branches on newer cpus when + we have real profile data, as static prediction overrides processor + dynamic prediction. For older cpus we may as well always hint, but assume not taken for branches that are very close to 50% as a mispredicted taken branch is more expensive than a mispredicted not-taken branch. */ if (rs6000_always_hint || (abs (prob) > REG_BR_PROB_BASE / 100 * 48 + && (profile_status_for_fn (cfun) != PROFILE_GUESSED) && br_prob_note_reliable_p (note))) { if (abs (prob) > REG_BR_PROB_BASE / 20