@@ -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);
new file mode 100644
@@ -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*-*-* } } } */
@@ -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);
@@ -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,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);