From patchwork Tue Nov 15 19:24:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 125860 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 75619B6F90 for ; Wed, 16 Nov 2011 06:27:41 +1100 (EST) Received: (qmail 971 invoked by alias); 15 Nov 2011 19:27:39 -0000 Received: (qmail 961 invoked by uid 22791); 15 Nov 2011 19:27:37 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Nov 2011 19:27:05 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RQOeu-0003l2-4Z from Tom_deVries@mentor.com ; Tue, 15 Nov 2011 11:27:04 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 15 Nov 2011 11:24:40 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 15 Nov 2011 19:27:01 +0000 Message-ID: <4EC2BC5B.1000408@mentor.com> Date: Tue, 15 Nov 2011 20:24:11 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" Subject: [PATCH] tail_merge_optimize frequency fix 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 Richard, this patch fixes up the basic block frequencies after merging 2 bbs in tail_merge_optimize, and prevents tree-dump messages like: 'Invalid sum of incoming frequencies x, should be y'. Bootstrapped and reg-tested on x86_64 and i686, build and reg-tested on ARM and MIPS. OK for trunk? Thanks, - Tom 2011-11-15 Tom de Vries * tree-ssa-tail-merge.c (replace_block_by): Add frequency of bb2 to bb1. * gcc.dg/pr43864.c: Check for absence of 'Invalid sum' in pre tree-dump. * gcc.dg/pr43864-2.c: Same. * gcc.dg/pr43864-3.c: Same. * gcc.dg/pr43864-4.c: Same. Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 181377) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -1396,6 +1396,9 @@ replace_block_by (basic_block bb1, basic pred_edge, UNKNOWN_LOCATION); } + bb2->frequency += bb1->frequency; + bb1->frequency = 0; + /* Do updates that use bb1, before deleting bb1. */ release_last_vdef (bb1); same_succ_flush_bb (bb1); Index: gcc/testsuite/gcc.dg/pr43864-2.c =================================================================== --- gcc/testsuite/gcc.dg/pr43864-2.c (revision 181377) +++ gcc/testsuite/gcc.dg/pr43864-2.c (working copy) @@ -19,4 +19,5 @@ f (int c, int b, int d) /* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */ /* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "pre"} } */ /* { dg-final { cleanup-tree-dump "pre" } } */ Index: gcc/testsuite/gcc.dg/pr43864-3.c =================================================================== --- gcc/testsuite/gcc.dg/pr43864-3.c (revision 181377) +++ gcc/testsuite/gcc.dg/pr43864-3.c (working copy) @@ -20,4 +20,5 @@ int f(int c, int b, int d) /* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */ /* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "pre"} } */ /* { dg-final { cleanup-tree-dump "pre" } } */ Index: gcc/testsuite/gcc.dg/pr43864-4.c =================================================================== --- gcc/testsuite/gcc.dg/pr43864-4.c (revision 181377) +++ gcc/testsuite/gcc.dg/pr43864-4.c (working copy) @@ -25,4 +25,5 @@ int f(int c, int b, int d) /* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */ /* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */ /* { dg-final { scan-tree-dump-times " - " 2 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "pre"} } */ /* { dg-final { cleanup-tree-dump "pre" } } */ Index: gcc/testsuite/gcc.dg/pr43864.c =================================================================== --- gcc/testsuite/gcc.dg/pr43864.c (revision 181377) +++ gcc/testsuite/gcc.dg/pr43864.c (working copy) @@ -32,4 +32,5 @@ hprofStartupp (char *outputFileName, cha } /* { dg-final { scan-tree-dump-times "myfree \\(" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "pre"} } */ /* { dg-final { cleanup-tree-dump "pre" } } */