From patchwork Fri Dec 30 16:50:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Melnik X-Patchwork-Id: 133685 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]) by ozlabs.org (Postfix) with SMTP id 13E17B6F9C for ; Sat, 31 Dec 2011 03:51:30 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1325868691; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=0yDcDuvlAINkziKsJhZe0HvnEmQ=; b=aIgVy5I9SkyBU+a qGV+CyoLdmjeaQULZywrMl2apYEGpahgw3VqEeJJ0rZwG8jqHRRCa62VzCcVZXal 95JJMgo3wLM7PYOhucLy2pxttUCSoibiPnyqN2ETPsgln21SFbhqVgWK0rDUp+dK JYax/A42+VkxwYHovuTSAQZXnJQ4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=PWCumFxE3xABC/+l9Ils5BBfLAIMLMEMt/NWbpxx78j36nr4VbHcFr7WJOGFxs IzIWIfO9w6QJXVPVw2p6b7EMI456F9i1lI3UFwXMn2ptCp6sbHG0McxkgaYVI9S1 uMXm4s2BifeibGFzALFFG3REh8QpRdghSYCIzrdp+B+AY=; Received: (qmail 31500 invoked by alias); 30 Dec 2011 16:51:25 -0000 Received: (qmail 31489 invoked by uid 22791); 30 Dec 2011 16:51:22 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.202) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Dec 2011 16:51:09 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 5830C5D4037; Fri, 30 Dec 2011 19:31:38 +0300 (MSK) Received: from [10.10.3.58] (winnie.ispras.ru [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id 9E8613FC48; Fri, 30 Dec 2011 19:51:06 +0300 (MSK) Message-ID: <4EFDEBE8.3090002@ispras.ru> Date: Fri, 30 Dec 2011 20:50:48 +0400 From: Dmitry Melnik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org, Andrey Belevantsev , Alexander Monakov , Ramana Radhakrishnan Subject: [RFC, ARM][PATCH 4/5] Limit on frequency in if-conversion References: <4EFDE957.6010104@ispras.ru> In-Reply-To: <4EFDE957.6010104@ispras.ru> X-IsSubscribed: yes 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 If one of branches has significantly greater probability than the other, then it may be better to rely on CPU's branch prediction and block reordering, than putting rarely executed instructions into the pipeline. In this patch we set 10% frequency ratio as a cutoff. On SPEC2K INT with -O2 this reduced code size for 28 bytes (no regressions). 2011-12-29 Dmitry Plotnikov gcc/ * ifcvt.c (cond_exec_process_if_block): Added check for frequency ratio. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index ce60ce2..330034e 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -445,6 +445,16 @@ cond_exec_process_if_block (ce_if_block_t * ce_info, int then_n_insns, else_n_insns, n_insns; enum rtx_code false_code; + /* If one of branches has significantly greater probability than the other, + then we'd better rely on CPU's branch prediction and block reordering + than putting rarely executed instructions into the pipeline. 10% ratio + seems like a reasonable cutoff. */ + if (then_bb && then_bb->frequency < (test_bb->frequency / 10)) + return FALSE; + + if (else_bb && else_bb->frequency < (test_bb->frequency / 10)) + return FALSE; + /* If test is comprised of && or || elements, and we've failed at handling all of them together, just use the last test if it is the special case of && elements without an ELSE block. */