From: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
To: Richard Biener <rguenther@suse.de>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <jh@suse.de>
Subject: Re: move increase_alignment from simple to regular ipa pass
Date: Thu, 02 Jun 2016 09:15:00 -0000 [thread overview]
Message-ID: <CAAgBjMnG8kLdu1Op7MsimPc-4-YosziE5pp8ysjvq1nxuxdygg@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1606020952230.1493@t29.fhfr.qr>
[-- Attachment #1: Type: text/plain, Size: 2606 bytes --]
On 2 June 2016 at 13:23, Richard Biener <rguenther@suse.de> wrote:
> On Thu, 2 Jun 2016, Prathamesh Kulkarni wrote:
>
>> On 1 June 2016 at 18:37, Richard Biener <rguenther@suse.de> 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 ?
>
> Currently the pass is only run for targets with section anchors (and there
> by default if they are enabled by default). So it makes sense to
> run on those by default and the pass is not necessary on targets w/o
> section anchors as the vectorizer can easily adjust alignment itself on
> those.
Ah indeed, thanks for explanation. Does the attached patch look OK
(stage-1 built) ?
I added new option -fipa-increase_alignment which is disabled by default
and only enabled on arm, aarch64 and ppc.
Thanks,
Prathamesh
>
> Richard.
>
>> Thanks,
>> Prathamesh
>> >
>> > Honza may have further comments.
>> >
>> > Thanks,
>> > Richard.
>> >
>> >> Thanks,
>> >> Prathamesh
>> >>
>> >
>> > --
>> > Richard Biener <rguenther@suse.de>
>> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
>>
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
[-- Attachment #2: ias2r_3.diff --]
[-- Type: text/plain, Size: 7316 bytes --]
diff --git a/gcc/common.opt b/gcc/common.opt
index fccd4b5..c964cf9 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1586,6 +1586,10 @@ fira-algorithm=
Common Joined RejectNegative Enum(ira_algorithm) Var(flag_ira_algorithm) Init(IRA_ALGORITHM_CB) Optimization
-fira-algorithm=[CB|priority] Set the used IRA algorithm.
+fipa-increase_alignment
+Common Report Var(flag_ipa_increase_alignment) Init(0) Optimization
+Option to gate increase_alignment ipa pass.
+
Enum
Name(ira_algorithm) Type(enum ira_algorithm) UnknownError(unknown IRA algorithm %qs)
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 51d2d50..f1c383f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -8251,6 +8251,8 @@ aarch64_override_options (void)
aarch64_register_fma_steering ();
+ /* Enable increase_alignment pass. */
+ flag_ipa_increase_alignment = 1;
}
/* Implement targetm.override_options_after_change. */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4e453fd..5aca5d0 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -3454,6 +3454,9 @@ arm_option_override (void)
/* Init initial mode for testing. */
thumb_flipper = TARGET_THUMB;
+
+ /* Enable increase_alignment pass. */
+ flag_ipa_increase_alignment = 1;
}
static void
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c6b2b6a..a046158 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5011,6 +5011,9 @@ rs6000_option_override (void)
= { pass_analyze_swaps, "cse1", 1, PASS_POS_INSERT_BEFORE };
register_pass (&analyze_swaps_info);
+
+ /* Enable increase_alignment pass. */
+ flag_ipa_increase_alignment = 1;
}
\f
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..ff9333e 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<cgraph_node *> (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<cgraph_node *> (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,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_ipa_increase_alignment != 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);
next prev parent reply other threads:[~2016-06-02 9:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 10:17 Prathamesh Kulkarni
2016-06-01 13:07 ` Richard Biener
2016-06-02 7:29 ` Prathamesh Kulkarni
2016-06-02 7:53 ` Richard Biener
2016-06-02 9:15 ` Prathamesh Kulkarni [this message]
2016-06-02 9:24 ` Prathamesh Kulkarni
2016-06-02 12:52 David Edelsohn
2016-06-02 12:57 ` Richard Biener
2016-06-02 15:01 ` Jan Hubicka
2016-06-03 7:57 ` Richard Biener
2016-06-03 8:05 ` Jan Hubicka
2016-06-07 8:34 ` Prathamesh Kulkarni
2016-06-08 14:15 ` Richard Biener
2016-06-08 15:09 ` Jan Hubicka
2016-06-09 20:18 ` Prathamesh Kulkarni
2016-06-09 20:23 ` Jan Hubicka
2016-06-10 9:33 ` Prathamesh Kulkarni
2016-06-10 11:17 ` Richard Biener
2016-06-13 8:57 ` Prathamesh Kulkarni
2016-06-13 10:43 ` Jan Hubicka
2016-06-14 13:02 ` Prathamesh Kulkarni
2016-06-17 14:22 ` Prathamesh Kulkarni
2016-06-23 17:21 ` Prathamesh Kulkarni
2016-06-28 9:27 ` Prathamesh Kulkarni
2016-07-05 9:53 ` Prathamesh Kulkarni
2016-07-20 11:49 ` Prathamesh Kulkarni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAgBjMnG8kLdu1Op7MsimPc-4-YosziE5pp8ysjvq1nxuxdygg@mail.gmail.com \
--to=prathamesh.kulkarni@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jh@suse.de \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).