From patchwork Thu Jun 2 07:29:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 69129 Delivered-To: patch@linaro.org Received: by 10.140.23.41 with SMTP id 38csp188364qgo; Thu, 2 Jun 2016 00:29:58 -0700 (PDT) X-Received: by 10.67.3.227 with SMTP id bz3mr3228099pad.67.1464852598848; Thu, 02 Jun 2016 00:29:58 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s15si56583087pfj.65.2016.06.02.00.29.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 00:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-428842-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-428842-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-428842-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:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=aBf1MzFQLURRS8s3Fw qe4ae+KaxF5I7kfdKvLwI3hAa9woy8FN8ODbMHdMv5AbDs3m1xwlcqk00nlWnPgs biIp6OTW3wsDsJ0m38GM9hoQe8XS5RIke3OvxFK99TlCQE4L6inopDfhtA99LHyl LJphKcgniQlraDyozB+WOne2Y= 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:date:message-id:subject :from:to:cc:content-type; s=default; bh=kE6k6UvviNawAQVRjy86DCwH +nc=; b=XME+MRaSORbuTH9LCUXaCtaM2gUzlFV6jETlQQAHL+u/V0DyRo/5KFe2 zAJ+AcGBZrKytQD0qP1jATk2NuwMNe06DCP8CjRW3WADrwFEWU7euBO4Qou3UN05 MhPE1IEiDb6O+IikMbir9WaootIIjD33CY4+UzrtnMVIcmneuFI= Received: (qmail 6386 invoked by alias); 2 Jun 2016 07:29:47 -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 5631 invoked by uid 89); 2 Jun 2016 07:29:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:dgrequ, sk:dg-requ, powerpc64*-*-*, powerpc64*** X-HELO: mail-it0-f49.google.com Received: from mail-it0-f49.google.com (HELO mail-it0-f49.google.com) (209.85.214.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 02 Jun 2016 07:29:35 +0000 Received: by mail-it0-f49.google.com with SMTP id i127so44385438ita.1 for ; Thu, 02 Jun 2016 00:29:35 -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:date :message-id:subject:from:to:cc; bh=xX7l8Ipa4n4srPTdC9OGiCauu7pbtooOqBW1npSv3Ws=; b=Zs1KovQYw3Ga5mi7Fos4X3peFloymbbfTSkybNhE3v/mMvHsw1Cnxjdo/bnV93rrAL cbVK7/NbTc7F9X39+ZB/oKcJVJU6jFXiCU7nEvVJwP+fFClRm8pFJj2tonZI1GStXctz ag8q7kt1iKaITj9jUDnvvq2FA2x9vpyT62O3iONpewjh984BODFzwMcEpdVj3t2YeXH1 Uo8Df7zOg/4hyEyYdJeJ1XbDsUtc4ppwYy0fa6l69uDKexjlA3JVmEOEOr5AoSZlyxnu ftnqVvINC4QEITjpi65olYsSOcHAZd/UT220Yk5/SzROoUjRlB+6BHy/hlutV3jkTBNH q29w== X-Gm-Message-State: ALyK8tLyvYM631Cagc5MlAjVbF8hHjTUTki6duQC0oJFmmFCw0x8aZEDy+uvlBLhWYdzuZ3r3U2Aoa9WbZc7+vbG MIME-Version: 1.0 X-Received: by 10.36.41.79 with SMTP id p76mr1974231itp.31.1464852573696; Thu, 02 Jun 2016 00:29:33 -0700 (PDT) Received: by 10.36.236.5 with HTTP; Thu, 2 Jun 2016 00:29:33 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 Jun 2016 12:59:33 +0530 Message-ID: Subject: Re: move increase_alignment from simple to regular ipa pass From: Prathamesh Kulkarni To: Richard Biener Cc: gcc Patches , Jan Hubicka X-IsSubscribed: yes On 1 June 2016 at 18:37, Richard Biener wrote: > On Wed, 1 Jun 2016, Prathamesh Kulkarni wrote: > >> Hi Richard, >> This patch tries to move increase_alignment pass from small to regular ipa pass. >> Does the patch look correct ? >> Since we are only increasing alignment of varpool nodes, I am not sure >> if any ipa >> read/write hooks were necessary and passed NULL for them. >> Cross-tested on arm*-*-*, aarch64*-*-*, >> Bootstrap+test on aarch64-linux-gnu in progress. > > I think the patch looks sensible apart from the fact that both > flag_section_anchors and flag_tree_vectorize can have different > states for each function. This would mean the pass should get > its own non-Optimization flag initialized by targets where > section anchors are usually used and it means you'd want to > walk IPA refs to see whether variables are used in a function > with both section anchors and vectorization enabled. Hi, I have attached patch (stage-1 built) that walks ipa-refs to determine if function has flag_tree_loop_vectorize and flag_section_anchors set. Does it look OK ? "This would mean the pass should get its own non-Optimization flag initialized by targets where section anchors are usually used" IIUC should we add a new option -fno-increase_alignment and gate the pass on it ? Um sorry I didn't understand why targets with section anchors (arm, aarch64, ppc) should initialize this option ? Thanks, Prathamesh > > Honza may have further comments. > > Thanks, > Richard. > >> Thanks, >> Prathamesh >> > > -- > Richard Biener > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg) diff --git a/gcc/passes.def b/gcc/passes.def index 993ed28..a841183 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/section-anchors-vect-73.c b/gcc/testsuite/gcc.dg/vect/section-anchors-vect-73.c new file mode 100644 index 0000000..74eaed8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/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 66e103a..2d2e8fc 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -482,7 +482,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..12ef019 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_vectorize && opts->x_flag_section_anchors)) + 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 && opts->x_flag_section_anchors)) + 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,11 +978,20 @@ 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: */ @@ -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);