From patchwork Tue Jul 31 13:50:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 174258 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 51A4F2C00A5 for ; Tue, 31 Jul 2012 23:50:24 +1000 (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=1344347425; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=im9Kjycl+VAG6bOV1b8AgAqlAGQ=; b=nusQMAIqMkCUfE2SwXfaO0o+UcXN8WCg8D6A8an5QPEFsYoqVTZS00FF6/ySxN qnAVNu59kccN0ioCL2qEkqTze7oo4voFzeb1y6Q/PGCiT6v+vEbcME3Ns1P86nZg 0o3HX6+P5O9DbKlONuRib++FclhHHmuBs4BPtYiUuFlBE= 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:X-Google-DKIM-Signature:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=shy0Biy1mt5SMJiXSzpVirc9TNoZeJyls5TnvBFs14dwkBXSBPX4062rkFMFCH 9GmPEkkwYIIYnIrMyGVCndjPNT6y2jtjuks3Vk9PmWFP/1kCQ1cYV0KRc8VIBYok Yp8Sas/J1geuDKwwDxTZZ1KDIedP2wwyyUw0tX+L1CJag=; Received: (qmail 310 invoked by alias); 31 Jul 2012 13:50:19 -0000 Received: (qmail 300 invoked by uid 22791); 31 Jul 2012 13:50:18 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_CF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jul 2012 13:50:05 +0000 Received: by pbbrq2 with SMTP id rq2so11390198pbb.20 for ; Tue, 31 Jul 2012 06:50:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=myROibQcXBGNN72g0LC5/FY1PcFzVY9hx1njAr4Ck1k=; b=Tlon+VPnrz10ms4JzgoRGKHEN4OkxgJrNyM0JypaY8fjDcMJGIaC3KyD5mW7lEziwk E2yJn+pW8XhZFHuCwWyejxsr9S/DETXfTu4Njh4VXUWPq6wQaRhZSBx8Q11wJdd2Xhhn 9qGjskrSChEs01+UKzvzmr8igT5d9806UFTpSui7tQHaTWTXsr1+Q64P4YkgxqviSX2+ 8H99J/HCxUXKPHHdvDvqakTTYzuBtvQLpE84QX88EtjL9B2csdErwp+nJwIHkwJn9hdC v6BABoNeJcjBTlronaFYPv+jbrr6pUlacw1A3TmtP1bvAg9FQVXTj4g5fLw3+tEIdpTe bZWA== Received: by 10.68.222.103 with SMTP id ql7mr43851382pbc.48.1343742604664; Tue, 31 Jul 2012 06:50:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.222.103 with SMTP id ql7mr43851343pbc.48.1343742604448; Tue, 31 Jul 2012 06:50:04 -0700 (PDT) Received: by 10.68.49.231 with HTTP; Tue, 31 Jul 2012 06:50:04 -0700 (PDT) In-Reply-To: <20120731124357.GE31362@kam.mff.cuni.cz> References: <20120731103814.GA16230@kam.mff.cuni.cz> <20120731105617.GD14221@kam.mff.cuni.cz> <20120731124357.GE31362@kam.mff.cuni.cz> Date: Tue, 31 Jul 2012 21:50:04 +0800 Message-ID: Subject: Re: [PATCH] Fix the LOOP_BRANCH prediction From: Dehao Chen To: Jan Hubicka Cc: Richard Guenther , gcc-patches@gcc.gnu.org, David Li X-System-Of-Record: true X-Gm-Message-State: ALoCoQkdg5fk79wiN9yFDfs4+TTypuHbI64NhjeVdFbq4PFZNc1BKmFL+6j/d/Y1FCLHsWjf2gAi8L18XzctvHSpH9HTtln+ZeE/zOe737zI1gQvZlmsKVgZ7RqvkEboPwkp+8G/l1zRwGmpfBNTIc1ef7jvnsjm5R86wwRhL1Edo4oE3wHR98IHp5mXB2Yyt7uwxQhUIuBA 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 Thanks, Honza, Then shall I check in the following patch to trunk (after testing)? Dehao On Tue, Jul 31, 2012 at 8:43 PM, Jan Hubicka wrote: >> On Tue, Jul 31, 2012 at 6:56 PM, Jan Hubicka wrote: >> >> > >> >> > Yeah, this may also work. The reason it is not done is that >> >> > 1) it seemed expensive to force CFG changes just to compute profile decade ago >> >> > 2) cfgcleanup afterwards will anyway remove the headers again. >> >> > So I originally hoped to do the right thing without normalization. >> >> >> >> Ok ... then you should pass AVOID_CFG_MODIFICATIONS instead. And be >> >> prepared for odd situations like this ;) >> > >> > Well, I guess we could do the extra work to avoid strange side cases like this. >> > Does normalization fix the testcase, too? >> >> Normalization indeed fixed this issue too. So what shall we do about >> this patch? Shall we simply change to use normalization instead? > > Yes, I think it is not _that_ expensive and we do some relatively tricky CFG > analysis there these days that should also get bit better. > (the code was written at a time CFG was new citizen to GCC and changes in CFG > was hard and considered harmful :) > > Honza >> >> Thanks, >> Dehao >> >> > >> > Honza >> >> >> >> > Honza Index: gcc/testsuite/gcc.dg/predict-7.c =================================================================== --- gcc/testsuite/gcc.dg/predict-7.c (revision 0) +++ gcc/testsuite/gcc.dg/predict-7.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar (int); + +void foo (int base) +{ + int i; + while (global < 10) + for (i = base; i < 10; i++) + bar (i); +} + +/* { dg-final { scan-tree-dump-times "loop branch heuristics" 0 "profile_estimate"} } */ +/* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/predict.c =================================================================== --- gcc/predict.c (revision 189835) +++ gcc/predict.c (working copy) @@ -2177,7 +2177,7 @@ { unsigned nb_loops; - loop_optimizer_init (0); + loop_optimizer_init (LOOPS_NORMAL); if (dump_file && (dump_flags & TDF_DETAILS)) flow_loops_dump (dump_file, NULL, 0);