summaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2006-08-03 20:35:05 +0000
committerDorit Nuzman <dorit@gcc.gnu.org>2006-08-03 20:35:05 +0000
commit0be79f24f8534db6eac81a35a94260d6a6f13eea (patch)
tree5600c4515b0df41a7300352395b0f3c145a96196 /gcc/cgraphunit.c
parent224aaa4139918fa03e1a490f99bcb8bfb35c91be (diff)
downloadgcc-0be79f24f8534db6eac81a35a94260d6a6f13eea.tar.gz
re PR middle-end/27770 (wrong code in spec tests for -ftree-vectorize -maltivec)
PR tree-optimization/27770 * tree-vectorizer.h (get_vectype_for_scalar_type): Function declaration removed (moved to tree-flow.h). (vect_can_force_dr_alignment_p): Likewise. * tree-flow.h (get_vectype_for_scalar_type): New function declaration (moved from tree-vectorizer.h). (vect_can_force_dr_alignment_p): Likewise. * tree-vectorizer.c (vect_print_dump_info): Allow calling this function from outside the vectorizer - in particular from cgraph stage. * tree-vect-analyze.c (vect_compute_data_ref_alignment): Don't increase the alignment of global arrays when -fsection-anchors is enabled. * cgraphunit.c (cgraph_increase_alignment): New function. (cgraph_optimize): Call cgraph_increase_alignment. From-SVN: r115910
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 256850224db..ddaecd3aa1c 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -172,6 +172,7 @@ static void cgraph_mark_functions_to_output (void);
static void cgraph_expand_function (struct cgraph_node *);
static tree record_reference (tree *, int *, void *);
static void cgraph_output_pending_asms (void);
+static void cgraph_increase_alignment (void);
/* Records tree nodes seen in record_reference. Simply using
walk_tree_without_duplicates doesn't guarantee each node is visited
@@ -1506,6 +1507,7 @@ cgraph_optimize (void)
/* This pass remove bodies of extern inline functions we never inlined.
Do this later so other IPA passes see what is really going on. */
cgraph_remove_unreachable_nodes (false, dump_file);
+ cgraph_increase_alignment ();
cgraph_global_info_ready = true;
if (cgraph_dump_file)
{
@@ -1565,6 +1567,51 @@ cgraph_optimize (void)
#endif
}
+/* Increase alignment of global arrays to improve vectorization potential.
+ TODO:
+ - Consider also structs that have an array field.
+ - Use ipa analysis to prune arrays that can't be vectorized?
+ This should involve global alignment analysis and in the future also
+ array padding. */
+
+static void
+cgraph_increase_alignment (void)
+{
+ if (flag_section_anchors && flag_tree_vectorize)
+ {
+ struct cgraph_varpool_node *vnode;
+
+ /* Increase the alignment of all global arrays for vectorization. */
+ for (vnode = cgraph_varpool_nodes_queue;
+ vnode;
+ vnode = vnode->next_needed)
+ {
+ tree vectype, decl = vnode->decl;
+ unsigned int alignment;
+
+ if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
+ continue;
+ vectype = get_vectype_for_scalar_type (TREE_TYPE (TREE_TYPE (decl)));
+ if (!vectype)
+ continue;
+ alignment = TYPE_ALIGN (vectype);
+ if (DECL_ALIGN (decl) >= alignment)
+ continue;
+
+ if (vect_can_force_dr_alignment_p (decl, alignment))
+ {
+ DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
+ DECL_USER_ALIGN (decl) = 1;
+ if (cgraph_dump_file)
+ {
+ fprintf (cgraph_dump_file, "Increasing alignment of decl: ");
+ print_generic_expr (cgraph_dump_file, decl, TDF_SLIM);
+ }
+ }
+ }
+ }
+}
+
/* Generate and emit a static constructor or destructor. WHICH must be
one of 'I' or 'D'. BODY should be a STATEMENT_LIST containing
GENERIC statements. */