From patchwork Sun Jun 14 08:55:59 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: 483927 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 DF50B140216 for ; Sun, 14 Jun 2015 18:56:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kVBSE6Ub; 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=e3bW4gwo1Irhr7o8m nxscIFQ463WtimdhgvJUk86cTECB+oxHbkE6X8SSTkIy1lcaOtGZHFhZ0r0MHVJx SZxtzZpz6pMnM9RIrScMAOCG8FNUInKhekHQ7CPgXxNg8GRoZLOIPijrv79roiHz wW8tLZQqsn8RK8aWajuB8Kv24s= 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=neZ2sKal7PTALjAPcPGuLUa YCw8=; b=kVBSE6UbI4pius893FA8YBTDsm81X/V3Ve2LX4FV9w8pMfO53xiz42U CJWiL+egrB4+Q3eBMHFR6Y0ghyQnvejzgFPGpi3Ny8ku4+zU97V7Gg7xBbdYXBKi P5nrk9Ag+t0FMW/wq/Sd2vyzXHzqXf2w6zXBStech1DB1F2B4PVg= Received: (qmail 88706 invoked by alias); 14 Jun 2015 08:56:15 -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 88675 invoked by uid 89); 14 Jun 2015 08:56:11 -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; Sun, 14 Jun 2015 08:56:09 +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 1Z43i1-0007He-7f from Tom_deVries@mentor.com ; Sun, 14 Jun 2015 01:56:05 -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; Sun, 14 Jun 2015 09:56:03 +0100 Message-ID: <557D419F.2090704@mentor.com> Date: Sun, 14 Jun 2015 10:55:59 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Richard Biener CC: GCC Patches Subject: Re: [PATCH, stage1] Make parloops gate more strict References: <5502BCA2.2010802@mentor.com> In-Reply-To: On 13/03/15 11:36, Richard Biener wrote: > On Fri, Mar 13, 2015 at 11:32 AM, Tom de Vries wrote: >> Hi, >> >> this patch moves a bunch of early-out tests from the parloops pass to the >> gate function. >> >> The only effect is for functions that we don't consider at all for >> parallelization in the parloops pass. We no longer dump those in the >> parloops dump file. >> >> Bootstrapped and reg-tested on x86_64. >> >> OK for stage1 trunk? > > Does it work with -fdump-passes? > Hi, with -fdump-passes now fixed to work on a dummy function (r222129), I'm resubmitting this patch, split up in two patches. The first patch moves two trivial early-exit tests to the parloops gate. The second patch moves the number_of_loops test to the parloops gate, and adds a dummy loops structure in the dummy function for -fdump-passes. Bootstrapped and reg-tested on x86_64. Both patches OK for trunk? Thanks, - Tom Move parloops::execute test to parloops gate 2015-06-11 Tom de Vries * cfgloop.c (init_loops_structure): Add and handle dummy_p parameter. (flow_loops_find): Add extra argument to call to init_loops_structure. * cfgloop.h (init_loops_structure): Add bool parameter. * cgraphunit.c (init_lowered_empty_function): Add extra argument to call to init_loops_structure. * lto-streamer-in.c (input_cfg): Same. * tree-cfg.c (move_sese_region_to_fn): Same. * passes.c (pass_manager::dump_passes): Add dummy loops structure to dummy function. * tree-parloops.c (pass_parallelize_loops::execute): Move early-exit test to .. (pass_parallelize_loops::gate): ... here. --- gcc/cfgloop.c | 19 +++++++++++-------- gcc/cfgloop.h | 2 +- gcc/cgraphunit.c | 2 +- gcc/lto-streamer-in.c | 2 +- gcc/passes.c | 4 ++++ gcc/tree-cfg.c | 2 +- gcc/tree-parloops.c | 6 ++---- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index a279046..2b17585 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -356,8 +356,8 @@ alloc_loop (void) (including the root of the loop tree). */ void -init_loops_structure (struct function *fn, - struct loops *loops, unsigned num_loops) +init_loops_structure (struct function *fn, struct loops *loops, + unsigned num_loops, bool dummy_p) { struct loop *root; @@ -366,11 +366,14 @@ init_loops_structure (struct function *fn, /* Dummy loop containing whole function. */ root = alloc_loop (); - root->num_nodes = n_basic_blocks_for_fn (fn); - root->latch = EXIT_BLOCK_PTR_FOR_FN (fn); - root->header = ENTRY_BLOCK_PTR_FOR_FN (fn); - ENTRY_BLOCK_PTR_FOR_FN (fn)->loop_father = root; - EXIT_BLOCK_PTR_FOR_FN (fn)->loop_father = root; + if (!dummy_p) + { + root->num_nodes = n_basic_blocks_for_fn (fn); + root->latch = EXIT_BLOCK_PTR_FOR_FN (fn); + root->header = ENTRY_BLOCK_PTR_FOR_FN (fn); + ENTRY_BLOCK_PTR_FOR_FN (fn)->loop_father = root; + EXIT_BLOCK_PTR_FOR_FN (fn)->loop_father = root; + } loops->larray->quick_push (root); loops->tree_root = root; @@ -427,7 +430,7 @@ flow_loops_find (struct loops *loops) if (!loops) { loops = ggc_cleared_alloc (); - init_loops_structure (cfun, loops, 1); + init_loops_structure (cfun, loops, 1, false); } /* Ensure that loop exits were released. */ diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index d811c56..e680941 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -260,7 +260,7 @@ struct GTY (()) loops { /* Loop recognition. */ bool bb_loop_header_p (basic_block); -void init_loops_structure (struct function *, struct loops *, unsigned); +void init_loops_structure (struct function *, struct loops *, unsigned, bool); extern struct loops *flow_loops_find (struct loops *); extern void disambiguate_loops_with_multiple_latches (void); extern void flow_loops_free (struct loops *); diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 722c4f4..d946b8f 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1392,7 +1392,7 @@ init_lowered_empty_function (tree decl, bool in_ssa, gcov_type count) | PROP_cfg | PROP_loops); set_loops_for_fn (cfun, ggc_cleared_alloc ()); - init_loops_structure (cfun, loops_for_fn (cfun), 1); + init_loops_structure (cfun, loops_for_fn (cfun), 1, false); loops_for_fn (cfun)->state |= LOOPS_MAY_HAVE_MULTIPLE_LATCHES; /* Create BB for body of the function and connect it properly. */ diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 1b83615..9139c35 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -844,7 +844,7 @@ input_cfg (struct lto_input_block *ib, struct data_in *data_in, return; struct loops *loops = ggc_cleared_alloc (); - init_loops_structure (fn, loops, n_loops); + init_loops_structure (fn, loops, n_loops, false); set_loops_for_fn (fn, loops); /* Input each loop and associate it with its loop header so diff --git a/gcc/passes.c b/gcc/passes.c index 720e647..4d89fce 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -993,6 +993,10 @@ pass_manager::dump_passes () const { push_dummy_function (true); + /* Push dummy loop. */ + set_loops_for_fn (cfun, ggc_cleared_alloc ()); + init_loops_structure (cfun, loops_for_fn (cfun), 1, true); + create_pass_tab (); dump_pass_list (all_lowering_passes, 1); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index b8a1c86..3bb7ea1 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7122,7 +7122,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* Initialize an empty loop tree. */ struct loops *loops = ggc_cleared_alloc (); - init_loops_structure (dest_cfun, loops, 1); + init_loops_structure (dest_cfun, loops, 1, false); loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES; set_loops_for_fn (dest_cfun, loops); diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index a1659a3..ef98878 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2657,7 +2657,8 @@ public: { return (flag_tree_parallelize_loops > 1 && !parallelized_function_p (fun->decl) - && !cfun->has_nonlocal_label); + && !cfun->has_nonlocal_label + && number_of_loops (fun) > 1); } virtual unsigned int execute (function *); @@ -2666,9 +2667,6 @@ public: unsigned pass_parallelize_loops::execute (function *fun) { - if (number_of_loops (fun) <= 1) - return 0; - if (parallelize_loops ()) { fun->curr_properties &= ~(PROP_gimple_eomp); -- 1.9.1