From patchwork Mon Mar 30 09:54:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 456036 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 DDE48140079 for ; Mon, 30 Mar 2015 20:54:45 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=td5X+efk; dkim-adsp=none (unprotected policy); 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=HZU9EDVCqrmoaPcYw LE/7tD9dQa6Ib6Vso3YPYjKv+Ut7+7xEoRJ+r3teDmxcrqpdvYj4HIJ3HrbmocO6 Qr8tvJYDlyQQx9PuCkLrrE+KfZYbHbJXxsUA2xYtW81mSWsodbcW+ODaCPmbaYi7 k11yRDTJ+7IEGYQng3E3rJDLGE= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=R5hA1AT6uImWPXrgNaMbMHB B8RQ=; b=td5X+efk8uDoafP3aUirKVyV+o3zaOIUvn7k9lffmMJ/bk3lWJnRa01 JMmxeTH91BcTmvayTj/kQujSYRmW0+bZoqIj6+P466avIuvZhv5Il3QkIe1/o+FT FaWR4Z6CYXtuwM9LzULDrFe3+dpkmDw6iTDCW2ZpbwwOAaBTAtIM= Received: (qmail 28973 invoked by alias); 30 Mar 2015 09:54:37 -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 28962 invoked by uid 89); 30 Mar 2015 09:54:36 -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; Mon, 30 Mar 2015 09:54:34 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YcWOs-0000vJ-5Y from Tom_deVries@mentor.com ; Mon, 30 Mar 2015 02:54:30 -0700 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.3.224.2; Mon, 30 Mar 2015 10:54:28 +0100 Message-ID: <55191D52.9040703@mentor.com> Date: Mon, 30 Mar 2015 11:54:26 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jan Hubicka CC: GCC Patches Subject: Re: [PATCH][PR65511] Fix edge probabilities in gimple_duplicate_sese_tail References: <551901E9.5040207@mentor.com> <20150330081551.GA28711@atrey.karlin.mff.cuni.cz> In-Reply-To: <20150330081551.GA28711@atrey.karlin.mff.cuni.cz> On 30-03-15 10:15, Jan Hubicka wrote: >> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c >> index 64bdc92..c7a7c4d 100644 >> --- a/gcc/tree-cfg.c >> +++ b/gcc/tree-cfg.c >> @@ -6177,6 +6177,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU >> gphi *phi; >> tree def; >> struct loop *target, *aloop, *cloop; >> + int exit_prob = exit->probability; >> >> gcc_assert (EDGE_COUNT (exit->src->succs) == 2); >> exits[0] = exit; >> @@ -6268,6 +6269,8 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU >> sorig = single_succ_edge (switch_bb); >> sorig->flags = exits[1]->flags; >> snew = make_edge (switch_bb, nentry_bb, exits[0]->flags); >> + snew->probability = exit_prob; >> + sorig->probability = REG_BR_PROB_BASE - exit_prob; > You need to also set snew->count/sorig->count. > Thanks for noting that. Updated patch. OK for stage1 if bootstrap and reg-test on x86_64 are ok? Thanks, - Tom Fix edge probabilities in gimple_duplicate_sese_tail 2015-03-27 Tom de Vries PR tree-optimization/65511 * tree-cfg.c (gimple_duplicate_sese_tail): Fix edge probabilities and counts. * gcc.dg/parloops-prob.c: New test. --- gcc/testsuite/gcc.dg/parloops-prob.c | 21 +++++++++++++++++++++ gcc/tree-cfg.c | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/parloops-prob.c diff --git a/gcc/testsuite/gcc.dg/parloops-prob.c b/gcc/testsuite/gcc.dg/parloops-prob.c new file mode 100644 index 0000000..a3e767c --- /dev/null +++ b/gcc/testsuite/gcc.dg/parloops-prob.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-fixup_cfg4-all" } */ + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void +f (unsigned int n) +{ + int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +/* { dg-final { scan-tree-dump-not "freq 0" "fixup_cfg4" } } */ +/* { dg-final { cleanup-tree-dump "fixup_cfg4" } } */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 64bdc92..6db6dff 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6177,11 +6177,18 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU gphi *phi; tree def; struct loop *target, *aloop, *cloop; + int exits_prob[2]; + gcov_type exits_count[2]; gcc_assert (EDGE_COUNT (exit->src->succs) == 2); exits[0] = exit; exits[1] = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit); + exits_prob[0] = exits[0]->probability; + exits_prob[1] = exits[1]->probability; + exits_count[0] = exits[0]->count; + exits_count[1] = exits[1]->count; + if (!can_copy_bbs_p (region, n_region)) return false; @@ -6268,6 +6275,10 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU sorig = single_succ_edge (switch_bb); sorig->flags = exits[1]->flags; snew = make_edge (switch_bb, nentry_bb, exits[0]->flags); + snew->probability = exits_prob[0]; + snew->count = exits_count[0]; + sorig->probability = exits_prob[1]; + sorig->count = exits_count[1]; /* Register the new edge from SWITCH_BB in loop exit lists. */ rescan_loop_exit (snew, true, false); -- 1.9.1