From patchwork Fri May 30 21:43:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 354350 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 6273A140086 for ; Sat, 31 May 2014 07:43:24 +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=sHPoJ9NvCJLsPx2PMkuWYzZ+ltlqceHlTXt8Sz9+Lff FMpopDe+5ZT+YleeCWLKEPPlKHn26/L8/fDaqFoB+ybJf2NELsRtTR2cWSuXqr0V 7MA6F0zl2r9DtDHQkPLRGK22jkB1AVPW9EYxTjdBUipmcB171dzAGJeletukKb50 = 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=kQcXvwRgUhrRZqApPzha/L02Vxk=; b=JGh0mYAcNlVBivthM ybO42vuTdPdpk+mL5dPNZHcsmaw+vszTNniIRqbQbmPJjVFQi1V/WG8egi21cxHg A/JeIT80H3zqHdFEvJYo3t/CNX9mMTKXTxCJytMOnmYc4FZc8VhHoQ/hbuVNknCi VDpwGzz3X2d7JIsTWw+Vfft1wA= Received: (qmail 7882 invoked by alias); 30 May 2014 21:43:17 -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 7856 invoked by uid 89); 30 May 2014 21:43:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f171.google.com Received: from mail-ie0-f171.google.com (HELO mail-ie0-f171.google.com) (209.85.223.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 30 May 2014 21:43:10 +0000 Received: by mail-ie0-f171.google.com with SMTP id to1so2344144ieb.16 for ; Fri, 30 May 2014 14:43:08 -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=t7lkeXeIKVpszy7qVSyuQUCfA9joOu4W5Qm5KgNAma0=; b=GSCUZnTlJYPmH0NgB4d9CusfFqePLtOC5NSwA3dyHrFu47O1mV8bM88D9EWsuCEP/M e0EecdgTNY/Jc6uhS8rhM+L/0PUSXucZJm+vDSkzl+B7XFCHOOVZolLYiylMUuXsDE/d f2jgdkMsYBKjGStp6BwsjjDvOsg40jKfjdou/rCBWegolT/ARfi0gL1LA6yOGDZYIooN 3dARKeoNMq4o1K0Mx4NoxptQNUGHFUhcAuZZuAJhZ0vpip6IdzXZe9UAHAiIheXFqH3Z bEthPYmpASKJWAFQklwWqLY/beffdSKx0aQZhcfqcSNF9t/5j8c02JNEChhzqlcJ/QWC ns1Q== X-Gm-Message-State: ALoCoQn2h/Hz81WWM125KfZfJFw8pjCxyXTAWEDKjp5t2Ful6/DRxM3r/JkhUB4HZOvZNa9OVe/h MIME-Version: 1.0 X-Received: by 10.51.15.161 with SMTP id fp1mr224259igd.25.1401486188637; Fri, 30 May 2014 14:43:08 -0700 (PDT) Received: by 10.64.240.97 with HTTP; Fri, 30 May 2014 14:43:08 -0700 (PDT) Date: Fri, 30 May 2014 14:43:08 -0700 Message-ID: Subject: [PATCH] Updates merged bb count From: Dehao Chen To: GCC Patches Cc: Jan Hubicka X-IsSubscribed: yes This patch updates the merged bb count only when they are in the same loop. Bootstrapped and passed regression test. Ok for trunk? Thanks, Dehao gcc/ChangeLog: 2014-05-30 Dehao Chen * tree-cfg.c (gimple_merge_blocks): Only reset count when BBs are in the same loop. gcc/testsuite/ChangeLog: 2014-05-30 Dehao Chen * gcc.dg/tree-prof/merge_block.c: New test. Index: gcc/testsuite/gcc.dg/tree-prof/merge_block.c =================================================================== --- gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-prof/merge_block.c (revision 0) @@ -0,0 +1,20 @@ + +/* { dg-options "-O2 -fno-ipa-pure-const -fdump-tree-optimized-blocks-details -fno-early-inlining" } */ +int a[8]; +int t() +{ + int i; + for (i = 0; i < 3; i++) + if (a[i]) + break; + return i; +} +main () +{ + int i; + for (i = 0; i < 1000; i++) + t (); + return 0; +} +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 211096) +++ gcc/tree-cfg.c (working copy) @@ -1880,8 +1880,11 @@ gimple_merge_blocks (basic_block a, basic_block b) /* When merging two BBs, if their counts are different, the larger count is selected as the new bb count. This is to handle inconsistent profiles. */ - a->count = MAX (a->count, b->count); - a->frequency = MAX (a->frequency, b->frequency); + if (a->loop_father == b->loop_father) + { + a->count = MAX (a->count, b->count); + a->frequency = MAX (a->frequency, b->frequency); + } /* Merge the sequences. */ last = gsi_last_bb (a);