From patchwork Thu Jun 9 20:18:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 69730 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp511951qgf; Thu, 9 Jun 2016 13:18:49 -0700 (PDT) X-Received: by 10.107.12.194 with SMTP id 63mr20628661iom.21.1465503529156; Thu, 09 Jun 2016 13:18:49 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id gk6si9137783pac.121.2016.06.09.13.18.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 13:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-429474-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-429474-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-429474-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=ve2fgIYhBHKt9UT 2Lti2VgzM/TqhuGhiIGv5HrvsFkC19TrQDhvDuTjg7iKg69LulOLkZ0LXEvF+v1o yHXrAld2gzay/Qnt+cgzSHgvx1845PRfjeWFTalrgGV+LiMb5kWQnVt4s7EoPU0S 17UTMHWOgsiktRPX/ALjCHvQ+NpE= 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=TA2BgWkdDdG9b2tcO/fDO D4TgME=; b=D6Xt04cLpwH27esvm08n8e7gCuJZViS8IxXEXv3zCmjA2sVzFcXcq ysf4wXvlPiFYn1O/4rJT4Afv4Qa3a9jhQyyKu0Xrxc6tHvHE3HyoGu2uI6jbmPeP YX2I98NP9ByKXSYKDWcVTt1cFvOGZXTZwMSBETGQ/qSeodF7jDS37w= Received: (qmail 129620 invoked by alias); 9 Jun 2016 20:18: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 129611 invoked by uid 89); 9 Jun 2016 20:18:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=varpool_node, sk:SYMBOL_, Seems, a.e X-HELO: mail-io0-f172.google.com Received: from mail-io0-f172.google.com (HELO mail-io0-f172.google.com) (209.85.223.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 09 Jun 2016 20:18:26 +0000 Received: by mail-io0-f172.google.com with SMTP id m62so48392245iof.0 for ; Thu, 09 Jun 2016 13:18:26 -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:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0l1E/y5bW/QJIEi2SjYrCUt+m1Njmrybf0qS7x2PS/0=; b=a6xOvgNbVxImEDAEIREGaGQx9ay3c8g6vsDyqMDZk3pacFb0AvodpYHMovYPPNyda5 bYPU2TeuVHDx/Jypl/bT9fB1ykOR/JHFw6zsRqHiLrH7ygLWLFLoqf84pxvSByh+qdTK nFH4UZuHGcLK3PH8K3CHTC711zoYCIRC/zxf1omHtaCK2XbzOjKnXFmEJRb3UGKdbnia AIadRe4e8S0J5LYs+imI5R329guQxgLEIx4h59I2l7dJTkaOrKVU3ApO7QSR/UhBIN+t aisBM9exgc8bIV4+fCLiUG0cgBJ1/dQrJyB4++B3pUs9pWI0pWXfUZTjbcqQN0vnuruw ZNOQ== X-Gm-Message-State: ALyK8tJWopxkrMLUYdEc+OIjqB146Cf/yWwDucVzRxwbgdsgSuw47mEIEPreOMx03jYUOVOnm5gH9x+dgVZvUnvn X-Received: by 10.107.130.195 with SMTP id m64mr2802989ioi.137.1465503504135; Thu, 09 Jun 2016 13:18:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.48.133 with HTTP; Thu, 9 Jun 2016 13:18:23 -0700 (PDT) In-Reply-To: <20160608150855.GB2550@atrey.karlin.mff.cuni.cz> References: <20160602150106.GA48112@kam.mff.cuni.cz> <20160603080543.GA78035@kam.mff.cuni.cz> <20160608150855.GB2550@atrey.karlin.mff.cuni.cz> From: Prathamesh Kulkarni Date: Fri, 10 Jun 2016 01:48:23 +0530 Message-ID: Subject: Re: move increase_alignment from simple to regular ipa pass To: Jan Hubicka Cc: Richard Biener , David Edelsohn , GCC Patches , "William J. Schmidt" , Segher Boessenkool X-IsSubscribed: yes On 8 June 2016 at 20:38, Jan Hubicka wrote: >> I think it would be nice to work towards transitioning >> flag_section_anchors to a flag on varpool nodes, thereby removing >> the Optimization flag from common.opt:fsection-anchors >> >> That would simplify the walk over varpool candidates. > > Makes sense to me, too. There are more candidates for sutff that should be > variable specific in common.opt (such as variable alignment, -fdata-sctions, > -fmerge-constants) and targets. We may try to do it in an easy to extend way > so incrementally we can get rid of those global flags, too. In this version I removed Optimization from fsection-anchors entry in common.opt, and gated the increase_alignment pass on flag_section_anchors != 0. Cross tested on arm*-*-*, aarch64*-*-*. Does it look OK ? > > One thing that needs to be done for LTO is sane merging, I guess in this case > it is clear that the variable should be anchored when its previaling definition > is. Um could we determine during WPA if symbol is a section anchor for merging ? Seems to me SYMBOL_REF_ANCHOR_P is defined only on DECL_RTL and not at tree level. Do we have DECL_RTL info available during WPA ? Thanks, Prathamesh > > Honza >> >> Richard. >> >> > Thanks, >> > Prathamesh >> > > >> > > Honza >> > >> >> > >> Richard. >> > >> > >> >> -- >> Richard Biener >> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) diff --git a/gcc/common.opt b/gcc/common.opt index f0d7196..f93f26c 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2133,7 +2133,7 @@ Common Report Var(flag_sched_dep_count_heuristic) Init(1) Optimization Enable the dependent count heuristic in the scheduler. fsection-anchors -Common Report Var(flag_section_anchors) Optimization +Common Report Var(flag_section_anchors) Access data in the same section from shared anchor points. fsee diff --git a/gcc/passes.def b/gcc/passes.def index 3647e90..3a8063c 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -138,12 +138,12 @@ along with GCC; see the file COPYING3. If not see PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) NEXT_PASS (pass_feedback_split_functions); POP_INSERT_PASSES () - NEXT_PASS (pass_ipa_increase_alignment); NEXT_PASS (pass_ipa_tm); NEXT_PASS (pass_ipa_lower_emutls); TERMINATE_PASS_LIST (all_small_ipa_passes) INSERT_PASSES_AFTER (all_regular_ipa_passes) + NEXT_PASS (pass_ipa_increase_alignment); NEXT_PASS (pass_ipa_whole_program_visibility); NEXT_PASS (pass_ipa_profile); NEXT_PASS (pass_ipa_icf); diff --git a/gcc/testsuite/gcc.dg/vect/aligned-section-anchors-vect-73.c b/gcc/testsuite/gcc.dg/vect/aligned-section-anchors-vect-73.c new file mode 100644 index 0000000..74eaed8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/aligned-section-anchors-vect-73.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-require-effective-target vect_int } */ + +#define N 32 + +/* Clone of section-anchors-vect-70.c with foo() having -fno-tree-loop-vectorize. */ + +static struct A { + int p1, p2; + int e[N]; +} a, b, c; + +__attribute__((optimize("-fno-tree-loop-vectorize"))) +int foo(void) +{ + for (int i = 0; i < N; i++) + a.e[i] = b.e[i] + c.e[i]; + + return a.e[0]; +} + +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target aarch64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target powerpc64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target arm*-*-* } } } */ diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 36299a6..d36aa1d 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -483,7 +483,7 @@ extern simple_ipa_opt_pass *make_pass_local_optimization_passes (gcc::context *c extern ipa_opt_pass_d *make_pass_ipa_whole_program_visibility (gcc::context *ctxt); -extern simple_ipa_opt_pass *make_pass_ipa_increase_alignment (gcc::context +extern ipa_opt_pass_d *make_pass_ipa_increase_alignment (gcc::context *ctxt); extern ipa_opt_pass_d *make_pass_ipa_inline (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_free_lang_data (gcc::context *ctxt); diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 2669813..d34e560 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -899,6 +899,34 @@ get_vec_alignment_for_type (tree type) return (alignment > TYPE_ALIGN (type)) ? alignment : 0; } +/* Return true if alignment should be increased for this vnode. + This is done if every function that references/referring to vnode + has flag_tree_loop_vectorize and flag_section_anchors set. */ + +static bool +increase_alignment_p (varpool_node *vnode) +{ + ipa_ref *ref; + + for (int i = 0; vnode->iterate_reference (i, ref); i++) + if (cgraph_node *cnode = dyn_cast (ref->referred)) + { + struct cl_optimization *opts = opts_for_fn (cnode->decl); + if (!opts->x_flag_tree_loop_vectorize) + return false; + } + + for (int i = 0; vnode->iterate_referring (i, ref); i++) + if (cgraph_node *cnode = dyn_cast (ref->referring)) + { + struct cl_optimization *opts = opts_for_fn (cnode->decl); + if (!opts->x_flag_tree_loop_vectorize) + return false; + } + + return true; +} + /* Entry point to increase_alignment pass. */ static unsigned int increase_alignment (void) @@ -916,7 +944,8 @@ increase_alignment (void) if ((decl_in_symtab_p (decl) && !symtab_node::get (decl)->can_increase_alignment_p ()) - || DECL_USER_ALIGN (decl) || DECL_ARTIFICIAL (decl)) + || DECL_USER_ALIGN (decl) || DECL_ARTIFICIAL (decl) + || !increase_alignment_p (vnode)) continue; alignment = get_vec_alignment_for_type (TREE_TYPE (decl)); @@ -938,7 +967,7 @@ namespace { const pass_data pass_data_ipa_increase_alignment = { - SIMPLE_IPA_PASS, /* type */ + IPA_PASS, /* type */ "increase_alignment", /* name */ OPTGROUP_LOOP | OPTGROUP_VEC, /* optinfo_flags */ TV_IPA_OPT, /* tv_id */ @@ -949,17 +978,26 @@ const pass_data pass_data_ipa_increase_alignment = 0, /* todo_flags_finish */ }; -class pass_ipa_increase_alignment : public simple_ipa_opt_pass +class pass_ipa_increase_alignment : public ipa_opt_pass_d { public: pass_ipa_increase_alignment (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_ipa_increase_alignment, ctxt) + : ipa_opt_pass_d (pass_data_ipa_increase_alignment, ctxt, + NULL, /* generate_summary */ + NULL, /* write summary */ + NULL, /* read summary */ + NULL, /* write optimization summary */ + NULL, /* read optimization summary */ + NULL, /* stmt fixup */ + 0, /* function_transform_todo_flags_start */ + NULL, /* transform function */ + NULL )/* variable transform */ {} /* opt_pass methods: */ virtual bool gate (function *) { - return flag_section_anchors && flag_tree_loop_vectorize; + return flag_section_anchors != 0; } virtual unsigned int execute (function *) { return increase_alignment (); } @@ -968,7 +1006,7 @@ public: } // anon namespace -simple_ipa_opt_pass * +ipa_opt_pass_d * make_pass_ipa_increase_alignment (gcc::context *ctxt) { return new pass_ipa_increase_alignment (ctxt);