From patchwork Thu Oct 22 18:59:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moore, Catherine" X-Patchwork-Id: 534540 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 A8E0B141331 for ; Fri, 23 Oct 2015 05:59:58 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KXIOZvWt; 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 :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=I4ciUtgaBLui/Uoa9Dkw7HLT//D7JwG2wn/hjyW/ylqqejQvgiEyc iv9DTRhRqFQ7Wmp0nMkggccyBtobjpL59/bMstu8QqeDQM3j1QHQEmO0JC4BSasA YgQooWh9eXn7MTr0KeWjyPtndY7uBsgADSy+p15QY1ShhuJRfV1PbQ= 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:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=OljGjiZ4D/OSin1hYcZtvRhiv2A=; b=KXIOZvWtgmD6fJ/VvWXAWbYOrJ+z 5ZIFgwyQa8O1X3ZdM/W90ebJRhL6tGIzfdIrEVMZBDxju9X1E70hP9StSPejXdQ/ lPkgf9ov5O7kgfa2m2v0QsRPxu049ZmPm3V2mCW4jlrri22i6p7F4A74+DOTzOHH EBcQfoVmae/1wTQ= Received: (qmail 115058 invoked by alias); 22 Oct 2015 18:59:52 -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 115041 invoked by uid 89); 22 Oct 2015 18:59:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Oct 2015 18:59:49 +0000 Received: from svr-orw-fem-05.mgc.mentorg.com ([147.34.97.43]) by relay1.mentorg.com with esmtp id 1ZpL5W-00075E-4L from Catherine_Moore@mentor.com ; Thu, 22 Oct 2015 11:59:46 -0700 Received: from NA-MBX-04.mgc.mentorg.com ([169.254.4.113]) by SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) with mapi id 14.03.0224.002; Thu, 22 Oct 2015 11:59:46 -0700 From: "Moore, Catherine" To: Robert Suchanek , Matthew Fortune , Richard Sandiford CC: "gcc-patches@gcc.gnu.org" Subject: RE: [PATCH] Disable -mbranch-likely for -Os when targetting generic architecture Date: Thu, 22 Oct 2015 18:59:45 +0000 Message-ID: References: <87y4h5iuwd.fsf@googlemail.com> <6D39441BF12EF246A7ABCE6654B0235321238501@LEMAIL01.le.imgtec.org> In-Reply-To: MIME-Version: 1.0 > -----Original Message----- > From: Robert Suchanek [mailto:Robert.Suchanek@imgtec.com] > Sent: Friday, September 04, 2015 10:21 AM > To: Matthew Fortune; Richard Sandiford > Cc: Moore, Catherine; gcc-patches@gcc.gnu.org > Subject: RE: [PATCH] Disable -mbranch-likely for -Os when targetting generic > architecture > > Hi, > > > Richard Sandiford writes: > > > Robert Suchanek writes: > > > > The patch below disables generation of the branch likely > > > > instructions for - > > Os > > > > but only for generic architecture. The branch likely may result > > > > in some code size reduction but the cost of running the code on R6 > > > > core is > > significant. > > > > > > How about instead splitting PTF_AVOID_BRANCHLIKELY into > > > PTF_AVOID_BRANCHLIKELY_SPEED and > PTF_AVOID_BRANCHLIKELY_SIZE? > > > We could have PTF_AVOID_BRANCHLIKELY_ALWAYS as an OR of the two. > > > > This sounds OK and is nicer. > > > > > Anything that does string ops on the architecture is suspicious :-) > > > > You can blame me for this. I advocated the string comparison approach > > as I had to do the same thing in gas IIRC for some feature and > > couldn't think of anything better to suggest. > > Here is an updated version that use the suggested method. Ok to apply? > > Regards, > Robert > > gcc/ > * config/mips/mips-cpus.def: Replace PTF_AVOID_BRANCHLIKELY > with > PTF_AVOID_BRANCHLIKELY_ALWAYS for generic architecture and > with > PTF_AVOID_BRANCHLIKELY_SPEED for others. > (mips2, mips3, mips4): Add PTF_AVOID_BRANCHLIKELY_SIZE to tune > flags. > * config/mips/mips.c (mips_option_override): Enable the branch > likely > depending on the tune flags and optimization level. > * config/mips/mips.h (PTF_AVOID_BRANCHLIKELY): Remove. > (PTF_AVOID_BRANCHLIKELY_SPEED): Define. > (PTF_AVOID_BRANCHLIKELY_SIZE): Likewise. > (PTF_AVOID_BRANCHLIKELY_ALWAYS): Likewise. > --- > gcc/config/mips/mips-cpus.def | 56 +++++++++++++++++++++--------------- > ------- > gcc/config/mips/mips.c | 6 +++-- > gcc/config/mips/mips.h | 20 ++++++++++++---- > 3 files changed, 47 insertions(+), 35 deletions(-) > > a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 0e0ecf2..f8775c4 > 100644 > --- a/gcc/config/mips/mips.c > +++ b/gcc/config/mips/mips.c > @@ -17916,8 +17916,10 @@ mips_option_override (void) > if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0) > { > if (ISA_HAS_BRANCHLIKELY > - && (optimize_size > - || (mips_tune_info->tune_flags & PTF_AVOID_BRANCHLIKELY) > == 0)) > + && ((optimize_size && (mips_tune_info->tune_flags > + & PTF_AVOID_BRANCHLIKELY_SIZE) == 0) > + || (!optimize_size && (mips_tune_info->tune_flags > + & PTF_AVOID_BRANCHLIKELY_SPEED) == > 0))) > target_flags |= MASK_BRANCHLIKELY; > else > target_flags &= ~MASK_BRANCHLIKELY; Should this check be: Instead? I don't see a use of PTF_AVOID_BRANCH_ALWAYS in your patch, but it seems like it should be checked. Index: mips.c =================================================================== --- mips.c (revision 229138) +++ mips.c (working copy) @@ -17758,8 +17758,15 @@ if ((target_flags_explicit & MASK_BRANCHLIKELY) == 0) { if (ISA_HAS_BRANCHLIKELY - && (optimize_size - || (mips_tune_info->tune_flags & PTF_AVOID_BRANCHLIKELY) == 0)) + && ((optimize_size + && (mips_tune_info->tune_flags + & PTF_AVOID_BRANCHLIKELY_SIZE) == 0) + || (!optimize_size + && optimize > 0 + && ((mips_tune_info->tune_flags + & PTF_AVOID_BRANCHLIKELY_SPEED) == 0)) + || (mips_tune_info->tune_flags + & PTF_AVOID_BRANCHLIKELY_ALWAYS) == 0)) target_flags |= MASK_BRANCHLIKELY; else target_flags &= ~MASK_BRANCHLIKELY;